Multi-Column sorting server-side (AJAX)
Multi-Column sorting server-side (AJAX)

I have been struggling to work out how to enable multiple column sorting serverside (AJAX) using DataTables v1.10. I am using the code below:
$('#search-results').DataTable({
processing: true,
serverSide: true,
searching: false,
//ordering: true,
//orderMulti: true,
deferRender: true,
dom: 'Bfrtip',
buttons: [
'print'
],
ajax: {
url: "/dataRetrievalUrl",
type: "GET",
data: function(data) {
data.Sku = $('#Sku').val();
data.SpecificationVersion = $('#SpecificationVersion').val();
data.SpecificationNumber = $('#SpecificationNumber').val();
}
},
columns: [
{ data: "ConceptId", orderable: true },
{ data: "ProductTitle", orderable: true },
{ data: "SpecificationNumber", orderable: true },
{ data: "SpecificationVersion", orderable: true },
{
data: "VersionId",
render: function(data, type, row, meta) {
return '<span class="view-document" data-version-id="' + data + '" data-file-type="' + row.FileType + '">View</span>';
},
sortable: false,
orderable: false
}
]
});
How would it be possible to get the datatable to send to the server the sort setting for each column.
Column Index
Sort Direction
On the server I can then construct my sort query accordingly.
This discussion has been closed.
Answers
I have just found that in order to get multiple columns sort columns to be sent to the server the SHIFT key must be held down when clicking the sort direction.
Data such as the following will be sent to the server:
order[0][column]=6
order[0][dir]=asc
order[1][column]=4
order[1][dir]=desc
Order column 6 ascending
then
Order column 4 descending