When I have two datatables on the page, and do filtering (search) on one of them, datatables can not distinguish between those two datatables and does search on both of them. What I'm doing wrong? Thanks!
How are you doing your filter? Using fnFilter() or the default input box? Here is an example of using multiple tables: http://datatables.net/examples/basic_init/multiple_tables.html . You can also use "$.fn.dataTableExt.iApiIndex" if you are using the API to tell DataTables which object it should use if you have created multiple tables with the initialiser: http://datatables.net/development/
Hi Allan,
thanks for quick reply. We are using default input box. Here is the example how we create two datatables:
[code]
$(document).ready(function() {
oTable = $('#table1').dataTable({
"bFilter": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "some_url.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "something" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
}).ajaxComplete(function(){
// Something1
});
In the code examples we saw that you are using one .dataTable call to initialize all the datatables on the page. But in that way we are not able do give different initialization options to our datatables. Any suggestion? Thanks!
Interesting - I've just tried the following initialiser on my demo page and it appears to work as expected:
[code]
$('.dataTable:eq(0)').dataTable();
$('.dataTable:eq(1)').dataTable();
$('.dataTable:eq(2)').dataTable();
[/code]
This is similar to what you've got, although no initialisation information, and not using server-side processing - although those functions should be wrapped up so tight that the scope isn't going to jump to something unexpected.
Do you have an example you could link to which shows the problem you are having? That would be most useful for tracing this one down!
Sorry, but when creating some tests we have failed to reproduce the error (which still exists in our production code). We will have to take a look at our code before coming back to you with the non working example. Thanks.
We have found the problem. It was not caused by the datatables, but the plugin called fnSetFilteringDelay. Here is the solution to the problem: http://datatables.net/forums/comments.php?DiscussionID=392&page=1#Item_0
Thanks, Allan.
Replies
How are you doing your filter? Using fnFilter() or the default input box? Here is an example of using multiple tables: http://datatables.net/examples/basic_init/multiple_tables.html . You can also use "$.fn.dataTableExt.iApiIndex" if you are using the API to tell DataTables which object it should use if you have created multiple tables with the initialiser: http://datatables.net/development/
Regards,
Allan
thanks for quick reply. We are using default input box. Here is the example how we create two datatables:
[code]
$(document).ready(function() {
oTable = $('#table1').dataTable({
"bFilter": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "some_url.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "something" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
}).ajaxComplete(function(){
// Something1
});
oTable2 = $('#table2').dataTable({
"bFilter": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "some_url2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "something2" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
}).ajaxComplete(function(){
// Something2
})
});
[/code]
In the code examples we saw that you are using one .dataTable call to initialize all the datatables on the page. But in that way we are not able do give different initialization options to our datatables. Any suggestion? Thanks!
Aca
Regardz,
Dusan
[code]
$('.dataTable:eq(0)').dataTable();
$('.dataTable:eq(1)').dataTable();
$('.dataTable:eq(2)').dataTable();
[/code]
This is similar to what you've got, although no initialisation information, and not using server-side processing - although those functions should be wrapped up so tight that the scope isn't going to jump to something unexpected.
Do you have an example you could link to which shows the problem you are having? That would be most useful for tracing this one down!
Regards,
Allan
Aca
Thanks, Allan.
Aca
Regards,
Dusan
Thanks for the update. Good to hear that there is already a solution for the issue :-)
Allan