How to prevent initial sorting

How to prevent initial sorting

palospalos Posts: 4Questions: 0Answers: 0
edited March 2009 in General
I would like have a table with normal sorting if a column is selected, but upon initial page load I would like to display the table as is. How would I go about doing this?

Thanks.

Replies

  • allanallan Posts: 57,679Questions: 1Answers: 9,193 Site admin
    Hi Palos,

    You can do what you are trying to achieve by passing in an empty array as the 'aaSorting' initialisation parameter. For example:

    [code]
    $(document).ready(function() {
    $('#example').dataTable( {
    "aaSorting": [ ]
    } );
    } );
    [/code]

    Allan
  • archimedearchimede Posts: 6Questions: 0Answers: 0
    edited May 2009
    I tried this tip but I get an "undefined" error at the following line:

    iDataSort = oSettings.aoColumns[ aaSort[aaSort.length-1][0] ].iDataSort;

    This is my code:

    [code]$(document).ready(function() {
    oTable=$('#test').dataTable( {
    "aaSorting": [ ], // Prevent initial sorting
    "aoData": [
    { "sType": "html" },
    null,
    null,
    ],
    "sPaginationType": "full_numbers"
    });
    });[/code]

    What am I doing wrong?

    TIA.

    Alessandro
  • allanallan Posts: 57,679Questions: 1Answers: 9,193 Site admin
    Hi Alessandro,

    Are you using the latest version of DataTables? 1.5 beta 7 (or 1.4.3 if you want to stick to the 1.4 series). There was a bug a while back where you couldn't set an empty sort - but it shouldn't be a problem any more.

    Allan
  • archimedearchimede Posts: 6Questions: 0Answers: 0
    Upgrading to 1.4.3 fixed it.

    Thanks a bunch!

    Regards.

    Alessandro
This discussion has been closed.