How to properly implement frontend code for server-side processing
How to properly implement frontend code for server-side processing
Hi, all!
I am new at programming. I want my datatable to support server-side processing and be able to support searching, filtering, and sorting. Regarding front-end I used simple example given in Examples -
$(document).ready(function () {
$('#events').DataTable({
"processing": true,
"serverSide": true,
"ajax": "/general/events"
});
..but seems it doesn't work when I try to search or paginate or filter. Which events should be added in that code? I cannot find complete example for that
This question has an accepted answers - jump to answer
Answers
Seems I need to add some event handlers for searching etc...
any suggestions?
You do not need to add any events - DataTables will do the events for you. If you are using server-side processing then you need to implement the server-side processing protocol. It sounds like that isn't happening at the moment.
How many rows do you have?
Allan
Hi, Allan!
I have now less than 10000 rows. But the project owner insists on implementing server-side processing for our tables.
Thanks for answer, I will try again
When I (finally) got server-side processing working, I ended up having to completely redesign all the server code. Once I realized that EVERY query to the database needed to handle additional page/sorting/searching parameters, I was able to quickly REwrite every database function. This was not clear at all from the docs, and caused me no end of frustration until I realized it.
While I got things working, I had TWO versions of every database function - one for dataTables server-side access, and one for everything else (including dataTables client-side access). The typical data access code for client-side and server-side are so different for the language I'm using that they will always be two separate styles.
Server-side is very cool when one finally gets it working.
Good to hear you got it working. The second paragraph on the server-side processing manual page does note:
Can you suggest a way that I could improve the documentation so others don't have the same frustration as yourself?
Thanks,
Allan
Maybe add more examples for paging etc. where each of sent parameters are shown and described.
Need to see how and where those sent parameters are used in code (I mean client side)
The point of that document isn't to detail how those parameters should be used in code, since that will be significantly different for each platform (for example PHP v Perl, or C# v Ruby), but rather to document what they are so you can implement support for them on the server-side.
Are the descriptions of the parameters not clear enough?
Allan