Problems with 2 datatables on the same page and filtering
Problems with 2 datatables on the same page and filtering
informax
Posts: 4Questions: 2Answers: 0
Hello, i have 2 different datatables on the same page and i have 2 diferent forms to filter the data of each datatable.
I`m using the $.fn.dataTable.ext.search.push() method, and it works fine when only one table. What should i do to make it work with 2 datatables?. Each of one has his own name and are attached to different html tables. Im using editor too.
This discussion has been closed.
Answers
You will probably need to create a search API as described in the Alphabet input search - Part III blog.
Kevin
Thanks, but thats not my problem. I allready have the search function attached to the $.fn.dataTable.ext.search.push() event.
Then problem is, i need different search functions for each datatable and when i have both datatables, the search function doesnt works
`$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var minTemp = $('#fechaInicio').val();
var temp = minTemp.split('/');
var min = new Date(temp[2], temp[1],temp[0],0,0,0,0);
You've found the major flaw in how the DataTables search plug-ins work at the moment. You need a bit of a hack
That will let you check in the function for the table id, and thus if that function should apply to the specified DataTable or not. So you need to have similar functions for your other tables.
A pain I know. That is something that will be addressed in the next major version.
Allan