Trouble implementing datatable server side (Php/mysqli)
Trouble implementing datatable server side (Php/mysqli)
guihamel
Posts: 10Questions: 0Answers: 0
Hi, in the past, I have used datatables succesfully in a server side situation.
I'm now faced having to use it again in a similar way but with major differences. In the first (and working) iteration, the datatable is showed on the main page (first tab) of the web page.
Now, on my 2nd app, the datatable is on a "secondary" page (the 5th tab) of the web page. If I put the $(document).ready(function() initialization in the main header, it breaks the rest of the site. I was wondering if it was possible to call the initialization in a different method.
As far as the query is concerned, I have validated the JSON output with jsonlint and it is all valid.
I'm now faced having to use it again in a similar way but with major differences. In the first (and working) iteration, the datatable is showed on the main page (first tab) of the web page.
Now, on my 2nd app, the datatable is on a "secondary" page (the 5th tab) of the web page. If I put the $(document).ready(function() initialization in the main header, it breaks the rest of the site. I was wondering if it was possible to call the initialization in a different method.
As far as the query is concerned, I have validated the JSON output with jsonlint and it is all valid.
This discussion has been closed.
Replies
You can initialise DataTables at any point you want, as long as the table node is in the document.
Allan
In the meantime, can you clarify what you mean by "as long as the table node is in the document" ??
Here, I uploaded 3 screenshot
1- my initialization code (that I added to my pageheader.php file)
2- the look of the main page after the code has been added (not a page with datatable)
3- what the page is supposed to look like.
Also, the actual datatable is located in the tab "Time Entry" and is never loaded properly.
I have added some javacript alerts to try and diagnose where the problem is happening and found out that an alert just before the initialization code is called, but one right after is never called.
As far as the node is concerned, it's located on the timeentry.php page. As a last resort, I moved my initialization on that page (timeentry) and it fixed the other pages back to their normal state but has yet to make my datatable work.
I also have made sure that the json output is valid.