Ajax Call - Order Column/ Direction in POST Missing in v2.2.2 (was working in v1.13.4)
Ajax Call - Order Column/ Direction in POST Missing in v2.2.2 (was working in v1.13.4)

Hi,
I have upgraded from DataBase Tables v1.13.4 tov 2.2.2 and have come across an issue with the Order instructions being sent via Ajax.
The initial Ajax call provides the order POST Array, but once you interact with the table, this variable is not always provided. We use this to sort the data on the Server. This issue appears when you navigate before all data is returned by the Server, or sort the SAME column again to toggle the direction.
order[0][column]: 0
order[0][dir]: desc
order[0][name]:
This doesn’t ALWAYS appear in a second Draw. Is this a defect? Or does there need to be a setting to ensure this variable is provided?
draw: 1
columns[0][data]: 0
columns[0][name]:
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: 1
columns[1][name]:
columns[1][searchable]: true
columns[1][orderable]: true
columns[1][search][value]:
columns[1][search][regex]: false
columns[2][data]: 2
columns[2][name]:
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]:
columns[2][search][regex]: false
order[0][column]: 0
order[0][dir]: desc
order[0][name]:
start: 0
length: 10
search[value]:
search[regex]: false
============================================
draw: 2
columns[0][data]: 0
columns[0][name]:
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: 1
columns[1][name]:
columns[1][searchable]: true
columns[1][orderable]: true
columns[1][search][value]:
columns[1][search][regex]: false
columns[2][data]: 2
columns[2][name]:
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]:
columns[2][search][regex]: false
columns[3][data]: 3
columns[3][name]:
columns[3][searchable]: true
columns[3][orderable]: true
columns[3][search][value]:
columns[3][search][regex]: false
start: 0
length: 10
search[value]:
search[regex]: false
Answers
You are almost certainly running into the fact that DataTables 2 introduced a new ordering state for columns - unordered. The default sequence is ascending, descending and then no order. Then it repeats. You can see this on any of the example tables when clicking the header.
When the third state (no order) is active, there is no ordering applied to the table, so it correctly doesn't send an
order
parameter in the server-side processing request.This can be controlled with the
columns.orderSequence
option, the docs for which also state how to set the default if you just want it to alternate betweenasc
anddesc
like 1.x did.Allan
I believe what you are seeing is a new order behavior introduced in Datatables 2. By default the first two clicks on a column header would order first ASC then DESC. A third click will remove the sorting of the column. See the
columns.orderSequence
for more details. The docs show using the following before Datatables is initialized to revert to the 1.x behavior:Kevin
Snap
Hi All,
You guys are amazing.
Many thanks for the prompt responses - and exmaple code. Let me give that a go this morning.
We should revert back to the v1 behaviour by default, especially for Ajax calls.