Detect when filter term is changed and remove column-based sorting
Detect when filter term is changed and remove column-based sorting
Hi All,
I'm trying to figure out how to remove/reset column filtering after the filter field (search) is used. I'm using server-side processing to display and sort data. Here's what I'm trying to do:
- Load a table with data and initially sort by date in descending order.
- Allow user to narrow results using filter field by inputting a string. Results are sorted by a custom search algorithm and table is refreshed.
- After the custom search field is used, any sorting applied by column should be removed (e.g. column is initially sorted by date but should no longer be sorted by date after a search).
- However, user should be able to sort by column after the filter field is used.
I've got it all working except for being able to remove the sorting after a new filter/search. Essentially what I'm looking to do is detect when the filter term is changed and remove any column-based sorting. I still want to allow the user to sort by column after they narrow down their results and this functionality should remain until the next filter/search causes it to reset.
I don't know if this will help but here's the js used to init the table:
[code]
$('#list').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax.php",
"aoColumns": [
null,
null,
null
],
"aaSorting": [[0,'desc']],
"oLanguage": { "sSearch": "" },
"bPaginate": false,
"sScrollY": calcTableHeight(),
"sScrollX": "100%",
"bScrollCollapse": true,
"bInfo": false
} );
[/code]
Thanks in advance!
Sean
I'm trying to figure out how to remove/reset column filtering after the filter field (search) is used. I'm using server-side processing to display and sort data. Here's what I'm trying to do:
- Load a table with data and initially sort by date in descending order.
- Allow user to narrow results using filter field by inputting a string. Results are sorted by a custom search algorithm and table is refreshed.
- After the custom search field is used, any sorting applied by column should be removed (e.g. column is initially sorted by date but should no longer be sorted by date after a search).
- However, user should be able to sort by column after the filter field is used.
I've got it all working except for being able to remove the sorting after a new filter/search. Essentially what I'm looking to do is detect when the filter term is changed and remove any column-based sorting. I still want to allow the user to sort by column after they narrow down their results and this functionality should remain until the next filter/search causes it to reset.
I don't know if this will help but here's the js used to init the table:
[code]
$('#list').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax.php",
"aoColumns": [
null,
null,
null
],
"aaSorting": [[0,'desc']],
"oLanguage": { "sSearch": "" },
"bPaginate": false,
"sScrollY": calcTableHeight(),
"sScrollX": "100%",
"bScrollCollapse": true,
"bInfo": false
} );
[/code]
Thanks in advance!
Sean
This discussion has been closed.