problem displaying several Datatables on one page
problem displaying several Datatables on one page
I've made a search result page that displays three different kinds of search results, differently structured, from different database tables. To make it more user friendly, I've put each of the 3 results into its own Datatable, and I've used a simple javascript tab control so that the user can switch between them, displaying one while the others are invisible. (I have only realized this for 2 of the 3 so far but ran into a problem.)
The datatables (the table IDs) have different names of course. Because I include code parts, there are two independent initializations with different names: $('#table1').DataTable() and $('#table2').DataTable() (with various settings).
Problem:
The first datatable that gets displayed works ok (I can programmatically set the first or the second one to be the first one displayed, and I can say that each of them works ok). Then when I switch to the other one, it looks ok at first sight but the controls (filter, pagination) no longer react. And when I switch back to the other one, the Datatables formatting is gone.
There are no errors in the browser console.
I've seen the demo page with two tables so it should theoretically work but I have no idea what is wrong. If necessary, I could write a test program.
This question has an accepted answers - jump to answer
Answers
Yes, in order to help debug we will need to see what you are doing. Please provide a test case.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
thx Kevin, I fixed it, there was a problem with the JS code for the tabs that I had found somewhere - I used another example page for tabs and now it works beautifully!