Respecting data order by in datatable

Respecting data order by in datatable

dlusignandlusignan Posts: 4Questions: 2Answers: 0

Hi,

I have a dataset that is previously fetch by date order DESC, but when table shows up the order is ASC. Any idea why the order from the dataset is not respected ? If I use "order": [0, DESC] (0 being the Date column), I can't reorder anymore.

Thank you.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    "order": [0, DESC]

    It should be:

     "order": [[0, 'desc']]
    

    It is case sensitive and should be a 2D array.

    Allan

  • dlusignandlusignan Posts: 4Questions: 2Answers: 0

    Hi Alan, thanks for the answer. Finally, It was an error in the generated code from the server the caused the problem.

    Thank you.

  • 11closed11closed Posts: 3Questions: 0Answers: 0

    aqui não deu, quero colocar a coluna 0 por ordem DESC, mas não da de jeito nenhum

    $(function() {
    $("#example2").dataTable({
    "order": [[0, 'desc']]
    });
    });

  • 11closed11closed Posts: 3Questions: 0Answers: 0

    here I did not give, I want to put column 0 in order DESC, but it does not at all

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    In order to help troubleshoot please provide a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    The issue is likely due to your data but without seeing your data in an example its hard to tell you what the issue is.

    Kevin

  • 11closed11closed Posts: 3Questions: 0Answers: 0

    I managed to fix it, the problem is that I just needed to update the script: "datatables" .js

This discussion has been closed.