Server does not receive current order/sort column
Server does not receive current order/sort column
DataTables 2.3.2
Firefox 140.0.4
Hi there!
const table = new DataTable('#orders',
{
ajax: '/dt?table-id=orders',
columns:
[
{data: 'timestamp',
render: DataTable.render.datetime('MMMM DD YYYY, HH:mm:ss')
},
{data: 'number'},
{data: 'source'},
{data: 'status'},
{data: 'email'}
],
order: [[0, 'desc']], // timestamp
lengthMenu: [20, 50], // page size selection
search:
{
return: false // filter as you type
},
processing: true,
serverSide: true
});
When receiving the query map in my callback (embedded HTTP server) I expected DataTables to reflect the user's order/sort selection much like it does by passing a searchable string. Instead, it always passes the predefined order column (index 0 = "timestamp") with "asc" or "desc". I called table.order() to find out what's the current internal order setting and it's correct, eg. if the user wants to sort on column "number" index 1 returns. So I wonder when calling table.ajax.reload() or table.ajax.url('/dt?table-id=orders').load() for a server side refresh why DataTables does not pass this up-to-date information, too?
This question has accepted answers - jump to:
Answers
Can you link to a test case showing the issue please?
I don't see anything there that would cause the
orderparameter that is being sent to the server on each request to not be the end user's sort column selection.Ordering works with server-side processing in this example, so I'd need to see a test case showing the problem please.
Allan
Thanks Allan
You're right: the current sorting columns are passed to my server: By mistake I ignored
to interpret order[0][column] = 1 for 1 being the index. It would have been clearer if the field would have been named order[0][index] = 1 instead
Frank
Hah, but it is index 0. There are two hard problems in computer science....
Good to hear you got it working.
Allan