Datables with server-side: true, sorting became faulty
Datables with server-side: true, sorting became faulty
TheNerdy97
Posts: 25Questions: 6Answers: 1
**https://codepen.io/TheNerdy97/pen/gOvNeeo?html-preprocessor=pug**:
**https://debug.datatables.net/ugucuh**:
**Everything is perfect but when I enable server-side and sort by any column the child-row disappears, and the sorting doesn't really show the highest or lowest values available **:
This question has an accepted answers - jump to answer
Answers
With server-side turned on everything is done on the server. If your displayed values are rendered the sorting will be incorrect in many cases. You need to do everything based on server values which in most cases are database values without any rendering. Search for orthogonal data to find a solution: e.g. return database values to the server and only render the "display" values to be able to still achieve proper client side sorting.
https://datatables.net/manual/data/orthogonal-data
Even if I pass only the DB values I still can't sort correctly as you saw in the example.
Both of your examples produce errors. I actually saw nothing.
Fixed the errors, never mind the images not loading.
https://codepen.io/TheNerdy97/pen/gOvNeeo?html-preprocessor=pug**:
@rf1234 @allan I recreated the problem in here:
https://codepen.io/TheNerdy97/pen/gOvNeeo?html-preprocessor=pug
@allan @rf1234 As I said the problem didn't disappear even if I show server values only without rendering
As rf1234 mentioned the sorting is handled by your server script with server side processing. Server side processing uses this protocol. You can look at the ssp.class.php script used in the server side processing examples to see the basic functionality needed.
Does your server script support the server side processing protocol and column sorting, etc?
Kevin
That's static data. That can't work with server-side processing. I wonder if you might be mixing up what server-side processing is and Ajax loading data. You can Ajax load data from a server and use client-side processing for sorting and filtering etc. See this part of the manual for a proper description.
Allan
That's for the sake of the example, as Codepen took too long to load the the original data
@allan In reality, I don't think that I need serverside processing, but when I use client-side my 1000 rows became only 50 rows.
Start by looking at the browser's network inspector tool to see the XHR response. How many rows are in the response?
Do you have a search plugin that might be filtering rows?
In the info element,
Showing 1 to 10 of 57 entries
for example, how many entires does it show?Kevin
Showing 1 to 10 of 50 entries
I want server-side also because every row of my table has child row with 100-200 image
That suggests the server is returning only 50 rows. Look at the XHR response in the browser's console.
As explained earlier you will need a server side processing script that supports the SSP protocol.
Kevin
The Module rest_framework_datatables was handling everything for serverSide, the problem was with one of the columns being integer but saved as text on the DB, so Sorting became faulty.