Replacing the default filter criteria
Replacing the default filter criteria
hammersmash
Posts: 15Questions: 0Answers: 0
I am trying to replace the default filter criteria. I want to keep the filter bar and all the plumbing, but I only want to filter rows that don't match my custom filter.
Specific case: Trying to keep all values unless a value is entered that matches a value in the list.
Specific case: Trying to keep all values unless a value is entered that matches a value in the list.
This discussion has been closed.
Replies
and use fnFilter with reg expression param set true.
I suppose I could compare the list returned against the total list and if the lists didn't match I would know that the value is present. I could then re-filter for the value and display those results in that case.
Yes to both.
> Actually, should fnFilter "" return all the values? That should also fire the custom filter?
As you say - yes to both. "" means no filter (if you want to match empty strings you would need to use regex) and fnFilter will indeed cause DataTables to apply all filters :-)
Allan
I ended removing the default filter element via sDom and adding my own which would fire fnFilter with an empty search term. I added the custom filter using $.fn.dataTableExt.afnFiltering. The reason I did this was to filter 2 tables from one search bar. Only the first table was filtered unless the search item matched something in the second table, then only the second table was filtered.
Not sure if this was the best method, any further advice? If not, thanks again anyways!
[code]
$(document).ready( function() {
$('#example').dataTable( {
"oSearch": {"sSearch": "Initial search"}
} );
} )
[/code]
Or in Javascript dotted object notation - oSearch.sSearch (sorry it should have been sSearch rather than sFilter that I put before!).
TO filter multiple tables, this plug-in API method might be of use to you: http://datatables.net/plug-ins/api#fnFilterAll
Allan