Two tables tab...search takes both tables
Two tables tab...search takes both tables
JCR1951
Posts: 34Questions: 6Answers: 0
I'm using datatables with tabs for two tables. (serverside data)
It seems to work.
But the search field looks likes it's searching in both tables together.
The pre-search doesn't work at all.
Can someone help please?
http://pctraverse.nl/DataTables-1.10.11/examples/server_side/simpleD.html
$('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
$.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
} );
.
.
.
// Apply a search to the second table for the demo
$('#exampleB').DataTable().search( 'melting' ).draw();
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You have 3 initializations of DataTables, that is 1 too many. Also, $('table.table') is applying to both tables, hence why you might be having the issue you are having. Move your DataTable initialization into a function, pass it the table ID, and return the DataTable.
Now call it
Thanks Gordon,
I thought I changed it like you did it.
But now I don't have data anymore from the database.
Please look at:
http://pctraverse.nl/DataTables-1.10.11/examples/server_side/simpleD.html
Most of the scripts I took from here:
https://datatables.net/examples/api/tabs_and_scrolling.html
Failed to load resource: the server responded with a status of 405 (Not Allowed)
simpleD.html:1 XMLHttpRequest cannot load http://code.jquery.com/jquery-1.12.0.min.js. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://pctraverse.nl' is therefore not allowed access. The response had HTTP status code 405.
I don't know what happened yesterday.
Tried it with one table at a time.
It worked.
After that it also works for 2 tables.
So the problem is gone!
Thanks for the help Gordon..
http://pctraverse.nl/DataTables-1.10.11/examples/server_side/simpleD.html