$.fn.dataTable.ext.search.pop() to specific Datatable
$.fn.dataTable.ext.search.pop() to specific Datatable
siva19susi
Posts: 2Questions: 1Answers: 0
I have the same $.fn.dataTable.ext.search.push() function running over two Datatable. But when I clear the search on one Datatable, the other should retain its filter and not get reset.
Do we have any below type code for pop also??
if(settings.nTable.id != tableName) {
return true;
}
Answers
Using
$.fn.dataTable.ext.search.push()
pushes onto to a Javascript array of searches. Datatables doesn't have a method to keep track. Its recommended to not pop the search plugins. Just add them all withpush()
then use conditions within to determine if the plugin should run.See this thread for Allna's answer to a similar question.
Kevin
Hi kthorngren,
In the thread reference you had given, there is a toggle operation. But in mine I am trying to move records between two tables. So records remain the same just the search-bar needs to work independent of each other. Push work like a charm but with the check. But without a pop I am unable reset the search result. Plus execution pop resets all tables even if I run an explicit table draw after pop.
As Kevin said, it would be better to use a condition, and just redraw the table with
draw()
to force the new search to take place.If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
I stumbled today over this too. searchPanes makes it a bit more complicated to get rid of an unknown amount of custom searches
Tried to describe it here.
In summary, this does the job in my case:
Many thanks for sharing that. This mixing of functions is most definitely something we need to address in future!
Allan