Initial sorting by aaSorting for multiple columns not working for ajax data

Initial sorting by aaSorting for multiple columns not working for ajax data

SibinSibin Posts: 4Questions: 2Answers: 0

I have two data tables in my project. First one is taking data from an array in my hand,
data table #1:

$('#table1').dataTable({
  "sPaginationType": "full_numbers",
  "iDisplayLength": 25,
  "aaSorting": [[7,'desc'],[2,'desc']],
  "bStateSave": true
});

In above table I got the result sorted as expected. But for my second table, which uses an ajax request for data, is not sorted as expected,
data table #2:

$('#table2').dataTable({
  processing: true,
  serverSide: true,
  ajax: 'a valid url',
  "aaSorting": [[3,'asc'],[0,'desc']],
  "bStateSave": false,
  "iDisplayLength": 25
});

I got the column with index 3 sorted but column with index 0 is not sorted for the same values of column 3. Do anyone is facing this kind of issue? Any help or suggestions invited.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586
    Answer ✓

    Hi @Sibin ,

    As you can see in this example here, it's working as expected. With serverSide, the server deals with the ordering (and paging, filtering, etc.), so it's likely to be an issue with the server responding with data in an incorrect order.

    Cheers,

    Colin

  • SibinSibin Posts: 4Questions: 2Answers: 0

    Thanks @colin I will check that.

This discussion has been closed.