How to sort the first column desc by default

How to sort the first column desc by default

swethagswethag Posts: 18Questions: 0Answers: 0
edited July 2012 in General
I want to sort the first(ID) column desc by default. Here is what i tried:
$(document).ready(function() {
$("#patientStoryLst").dataTable({
"sPaginationType" : "full_numbers",
"iDisplayLength " : 5,
"bJQueryUI" : true,
"sDom" : '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>',
"aoColumns": [ { "asSorting": [ "desc", "asc" ] },
{ "bSortable": false },
null, null,null,null,null, null,null,null,null,null ]

});


});

but the first column is not sorted desc order by default.
can anybody help me?

Replies

  • foleylfoleyl Posts: 2Questions: 0Answers: 0
    Hi,

    If you would like to sort the on the first column in descending order, you could apply the following:

    [code]
    $(document).ready(function() {
    $("#patientStoryLst").dataTable({
    "sPaginationType" : "full_numbers",
    "iDisplayLength " : 5,
    "bJQueryUI" : true,
    "sDom" : '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>',
    "aoColumns": [ {"bSortable": false }, null, null, null, null, null, null, null, null, null,null ],
    "aaSorting": [ [0,'desc'] ]
    });
    });
    [/code]

    The relevant section added here being the aaSorting options.

    Cheers,
    Luke
This discussion has been closed.