Inverse fnFilter()?
Inverse fnFilter()?
I'm trying to search for items in a column that don't contain a specific value. I've tried many regex's and am struggling to find a way to negate the text to match.
Normally you'd just do something like:
[code]var bMatches = !regex.match("something");[/code]
Is there a way to get fnFilter to negate the search?
Normally you'd just do something like:
[code]var bMatches = !regex.match("something");[/code]
Is there a way to get fnFilter to negate the search?
This discussion has been closed.
Replies
http://www.datatables.net/examples/plug-ins/range_filtering.html
Essentially I want to leave the default search box to work as normally, but I have a checkbox that toggles what records are visible and aren't. This works fine on other tables, but this one has a cell value of a load of HTML that I'm struggling to do a negative match on.
Are the values in a single column? If so, then using fnFilter and a regular expression is very much the way to go. You should also disable smart filtering (an fnFilter parameter) as DataTables uses its own regex for that, and it would interfere with your own regex.
Allan
I had to call time on it, so I'm working around this by seeding the cell value with something I can match on, but it means extra work when I have to remove this later on as part of a persistence and re-filter scenario.
It seems to be a common regex problem that has to be worked around by inverting the calling logic, but of course that's wrapped up in DataTable. Perhaps a parameter on fnFilter to invert the match would be useful to others?
Allan
Thanks anyhow Allan :)
Allan
Until then, what you can do to have it apply to only a specific table is a condition at the top of the plug-in function that will check if it is the table that you want the filter to operator on or not. If it isn't then return true (i.e. apply no filter). Is it is, then do what is needed.
Not perfect I'm sorry to say, but possible :-)
Allan
Regards,
Allan