fnSort from separate link, have to click twice on column header

fnSort from separate link, have to click twice on column header

RichinMNRichinMN Posts: 2Questions: 0Answers: 0
edited October 2013 in Bug reports
Looking for a workaround to the following issue - maybe it is a code problem on my part...

My stripped-down example here: http://live.datatables.net/ujiduk

You can toggle the sorting back and forth using separate links which call fnSort, the sorting also toggles back and forth using the column headers - however - if you sort using the links until a column is ascending, then click on the column header, nothing happens (until the second click, at which point it goes descending).

So to reproduce, load my example at the link above, click "Sort Col B" which sorts Col B ascending, and then click on the "Col B" column header, which should reverse the sort... nothing happens.

Inspecting the changes that occur in the html on the columnheader when you call fnSort, you can see that the "class" changes from "sorting_asc" to "sorting_desc", something called "aria-sort" changes from "ascending" to "descending", however the "aria-label" does not change (it always reads "...activate to sort column ascending").

I am hoping there is a workaround for this where I can watch an event, force a refresh, or maybe toggle a value that isn't being toggled somewhere, or maybe I missed something in my sort code.

Thanks!
-Rich

Replies

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    So the problem here is that internally DataTables keeps a track of the sorting applied from the asSorting array. However, when using fnSort, that information isn't available so it effectively gets reset.

    The good news is that I've reworked this in DataTables 1.10 (which is currently pre-beta) so that problem no longer exists (or rather, DataTables is a bit more smart about it): http://live.datatables.net/ujiduk/3/edit .

    Allan
  • RichinMNRichinMN Posts: 2Questions: 0Answers: 0
    That is great, we will be standing by for the next release - thanks!
This discussion has been closed.