Use search plug-in on only one table with a page with multiple tables
Use search plug-in on only one table with a page with multiple tables
torple
Posts: 5Questions: 1Answers: 0
What is the best practice to handle a search plug-in needed for a single table on a page with multiple tables? My plan is to implement something like
$.fn.dataTable.ext.search.push(
function( settings, searchData, index, rowData, counter ) {
if (settings.sTableId !== 'my-table-id') {
return true;
}
...
}
);
This should ignore my other tables, correct? Is there a better way to address this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This thread should answer your question:
https://datatables.net/forums/discussion/comment/76746/#Comment_76746
Kevin
That's great information, thank you. It appears I'm on the right track, and I can see the plugin function being called.
However, when my next datatable loads, my plugin function has been removed from $.fn.dataTable.ext.search. Looking through the code, it appears global settings are reinitialized with every new table. Is this correct? If so, I can make sure the plugin is set when my target table in use, but I want to verify before I go down that path.
Here is what I am working with:
Making sure my plugin function is set, along with returning true for any table that's not the table in question, looks to be the way to go.