How to properly implement frontend code for server-side processing

How to properly implement frontend code for server-side processing

future.fogfuture.fog Posts: 5Questions: 1Answers: 0

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

  • future.fogfuture.fog Posts: 5Questions: 1Answers: 0

    Seems I need to add some event handlers for searching etc...

  • future.fogfuture.fog Posts: 5Questions: 1Answers: 0

    any suggestions?

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    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

  • future.fogfuture.fog Posts: 5Questions: 1Answers: 0

    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

  • gcurrie333gcurrie333 Posts: 6Questions: 1Answers: 0

    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.

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Good to hear you got it working. The second paragraph on the server-side processing manual page does note:

    When using server-side processing, DataTables will make an Ajax request to the server for each draw of the information on the page (i.e. when paging, ordering, searching, etc.). DataTables will send a number of variables to the server to allow it to perform the required processing and then return the data in the format required by DataTables.

    Can you suggest a way that I could improve the documentation so others don't have the same frustration as yourself?

    Thanks,
    Allan

  • future.fogfuture.fog Posts: 5Questions: 1Answers: 0
    edited May 2016

    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)

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    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

This discussion has been closed.