Why my default sorting setting is not working?

Why my default sorting setting is not working?

daxudaxu Posts: 2Questions: 1Answers: 0

Hi,
I want to set sorting to be 4th column, but no matter, what I try, it always sorted on the first column. What I am doing wrong?

$('#example').dataTable( {
""ajax": {
"url": "api/fundlist/",
"type": "POST"
},
"aaSorting": [[3,'desc']],
"columns": columns,
"fnDrawCallback":SetTooltip
} );

Many Thanks

Answers

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    Per the forum rules, please link to a test case showing the issue. The code you have looks okay, so we would need a test case to debug.

    Allan

  • daxudaxu Posts: 2Questions: 1Answers: 0

    Seems there is a bug in
    function _fnLoadState ( settings, oInit )
    {
    }

    For whatever reason, the state remembers the ordering of previous ordering. So if I didn't change column number, but just change the default ordering, the previous state will override what I set as a default.

    This doesn't sound very right for me.

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    Actually, to my mind that sounds exactly correct (btw, your code above doesn't show the use of state saving - I might have been able to guess this, but it highlights why test cases are important, so I have all the information required to be able to help :-) ).

    The reason it sounds correct is that the default state is not stored in the state data, so the state information can only restore what the last sorting on the table was. If the ordering given in the initialisation was used, then there would never be any state saving!

    Allan

This discussion has been closed.