Two clicks required to re-sort initial sorted column

Two clicks required to re-sort initial sorted column

jclarke0000jclarke0000 Posts: 2Questions: 0Answers: 0
edited May 2014 in DataTables 1.10

Hi

I'm using columnDefs to make the default sorting sequence "desc", "asc" such that all columns sort descending first, followed by ascending on the second click. I'm also using "sorting" to specify the first column to be sorted "desc."

When the table first loads, the table is sorted as I want it to, but if I want to change the sort direction (i.e. to "asc") I need to click the column header for the first column twice. After that sorting behaves normally. It is as if the first click applies "desc" sorting as if it wasn't previously sorted.

Here is a link to a fiddle which demonstrates the behaviour:

http://live.datatables.net/mawihib/1/edit?js,output

Notice how it takes two clicks on the "Name" header to change its sort order.

Do I need to specify an additional parameter upon initialization to fix this?

Thanks!
- Jeff

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    Thanks for the test case! I think this is a little bug in DataTables... It should be able to cope with this, but it isn't quite there.

    Having said that, there is an easy workaround you can use immediately. Simply give your sorting array as a 2D array, rather than 1D. In 1.9- you used to always have to give it a 2D array, but that was relaxed in 1.10. It looks like the handling of the initial sort detection didn't keep pace...

    Example here: http://live.datatables.net/mawihib/2/edit

    Regards,
    Allan

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    edited May 2014

    Fix committed :-)

    Regards,
    Allan

  • jclarke0000jclarke0000 Posts: 2Questions: 0Answers: 0

    Awesome!

    Thanks.

This discussion has been closed.