turn off automatic date sorting

turn off automatic date sorting

ningurbananingurbana Posts: 3Questions: 0Answers: 0
edited May 2010 in General
My data needs the lastest date on top instead of the oldest on top. But by initial loading of datatable, it always sort the date from oldest->latest by ignoring my own date ordering. How do I turn off this initial date sorting functionality?

--Ning

Replies

  • StevenSteven Posts: 5Questions: 0Answers: 0
    I had the same problem. This is my code:


    $(document).ready(function() {
    $('#example').dataTable( {
    "aaSorting": [ ]
    } );
    } );
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    aaSorting is the way to go here: http://datatables.net/usage/options#aaSorting

    An empty array like Steven has will disable initial sorting, or you can reverse the default and put in: [[0,'desc']].

    Yet another option is to use asSorting ( http://datatables.net/usage/columns#asSorting ) to set the sorting order priority for your date columns :-)

    Regards,
    Allan
This discussion has been closed.