How to reset fnFilter if you had defined your own?
How to reset fnFilter if you had defined your own?
mjdinsmore
Posts: 10Questions: 1Answers: 0
DataTables is a great jQuery tool -- thanks!
I am extending the filtering so that my users can match _all_ the words or _any_ or the words. Basically an AND/OR functionality with the filtering. I have a regex defined (defined as searchRegex) for the OR which dynamically creates the regex and passes that into the DataTable (defined as oTable):
[code]
oTable.fnFilter( searchRegex, null, true, false );
[/code]
and I autogenerate an HTML dropdown which I place after the ".dataTables_filter input". My problem is how to reset the defined filter I had so that it returns to the default seach implementation when the table is first drawn? Do I need to come up with the regular expression that DataTables uses or is there some other mechanism for this. The "oTable.fnFilterClear();" method only clears the filter, but does not remove my defined filter so that is can return to the default DataTable search.
To be clear, my question isn't about how to write the jQuery/Javascript to allow this functionality but the method to reset the DataTable filtering mechanism so it can override my defined filter. I'd be happy to share the code if anyone is interested once it's working.
Thanks.
I am extending the filtering so that my users can match _all_ the words or _any_ or the words. Basically an AND/OR functionality with the filtering. I have a regex defined (defined as searchRegex) for the OR which dynamically creates the regex and passes that into the DataTable (defined as oTable):
[code]
oTable.fnFilter( searchRegex, null, true, false );
[/code]
and I autogenerate an HTML dropdown which I place after the ".dataTables_filter input". My problem is how to reset the defined filter I had so that it returns to the default seach implementation when the table is first drawn? Do I need to come up with the regular expression that DataTables uses or is there some other mechanism for this. The "oTable.fnFilterClear();" method only clears the filter, but does not remove my defined filter so that is can return to the default DataTable search.
To be clear, my question isn't about how to write the jQuery/Javascript to allow this functionality but the method to reset the DataTable filtering mechanism so it can override my defined filter. I'd be happy to share the code if anyone is interested once it's working.
Thanks.
This discussion has been closed.
Replies
I am looking for a way to have a button which can clear all filters and search box, something like show all or reset search and search filters.
So if you can send me some ideas or solution, it will really good.
Thanks