fnSortNeutral fails with new API

fnSortNeutral fails with new API

cpowercpower Posts: 11Questions: 3Answers: 2
edited March 2015 in Free community support

Is there a way to make fnSortNeutral work with the new API? It worked with the old API but once I try to use the new API (DataTable()), the functionality is not working any more:

http://live.datatables.net/foloqaki/1/edit
changing dataTable to DataTable and the alert is not happening.

Thanks in advance!

Answers

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    Hi,

    I've just put together an equivalent method for the new API. I've committed it to the plug-ins repo so it will be included on this site in the next release.

    I've updated your example to use this new method here: http://live.datatables.net/foloqaki/2/edit

    Allan

  • cpowercpower Posts: 11Questions: 3Answers: 2

    Thank you very much Allan!

  • cpowercpower Posts: 11Questions: 3Answers: 2

    Allan, I have a question regarding your new API. what is the reason to include the two lines:
    s.aiDisplay.sort();
    s.aiDisplayMaster.sort();

    I am actually getting weird sorting results after the sorts. The resetting the aaSorting array length to 0 seems to do the trick for me already. Thanks!

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    what is the reason to include the two lines: s.aiDisplay.sort(); s.aiDisplayMaster.sort();

    Those two arrays are the internal index arrays that DataTables uses for the display order of the rows. So sorting them just puts them back into numeric order.

    The original plug-in had that as well. Not sure why I put a custom sort function in it before, that doesn't seem to be needed.

    If all you want to do is clear the current ordering, then you can use order() and just pass in an empty array. Beyond that I would need a link to your page to be able to debug what is happening.

    Allan

  • cpowercpower Posts: 11Questions: 3Answers: 2

    Ah, I now remember why I was trying to use the fnsortneutral function, it's because I can't seem to get order() work with an empty array in the first place.

    http://live.datatables.net/foloqaki/3/edit

    As you can see, the order of the table stays after the initialization. the order([]) does not revert it back to the unsorted state. Thanks!

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    Right - that's what the sort on the two arrays you asked about does. Returns the display to the original load order.

    If the new method isn't working for you, a test case with it would be fantastic.

    Allan

This discussion has been closed.