Server side sorting
Server side sorting
MarekAdam
Posts: 30Questions: 9Answers: 1
Link to test case: https://editor.datatables.net/examples/standalone/collection.html
Description of problem:
I use standalone like in link but i have verticaly div. Many divs in many tabs. All works ok but i need to sort data by date. How to do it?
Give any parametr to ajax or somenthing like ->order (not working) in php file?
This question has an accepted answers - jump to answer
Answers
Does that mean you are using server side processing, ie
serverSide: true
? If so the server script is responsible for querying the data with the appropriate sorting. Are you using a Datatables supplied server side processing script?See the Server side processing protocol docs for details of the parameters sent. You will see there is an
order[i][column]
andorder[i][dir]
parameter for each column. Your server script will need to use this to build the appropriate query.If you still need help then please provide more details about your solution especially the server side.
Kevin
My code is almost the same as in the example. The main difference is that there is leftJoin in php and appropriate changes in js.
php file is standard.
The problem is that there is no classic "new DataTable" call here and I don't know how to do it in js or php. I would also like to refresh the table with a button (normally I can do it) but I have no idea how to do it here
Sorry I misunderstood the question - you aren't using Datatables nor server side processing.
The panels are being loaded on the page in the order of the JSON response. I see two options:
ORDER BY
to sort the date field.Kevin
->order_by
instanceI found an interesting workaround on the forum, but I don't know why it doesn't work. I add:
In debuging console i see good sql query. When i paste it to phpmyadmin its working but on my page still is order by ID. Why? I have no sorting in JS.
Correct query. You can close the topic. Great script, thanks guys for the good job!