Using `orderData` applies sorting arrow styling to wrong column

Using `orderData` applies sorting arrow styling to wrong column

TobiasBgTobiasBg Posts: 13Questions: 1Answers: 0

Hi Allan,

I hope you are doing well! I think I might have found a bug:

Description of problem:
When using columnDefs.orderData in DataTables 2.1.8, the sorting arrow icons are not toggled in the "target" column but in the (potentially hidden) column with the "orderData".
The expected result would be that the sorting arrow icons are updated in the sorted-on column, as is the case with DataTables 1.13.11.

Testcase with DataTables 2.x (nightly): https://live.datatables.net/jivalori/1/edit?html,js,output (wrong behavior)
Testcase with DataTables 1.13.11: https://live.datatables.net/biqogobi/1/edit?html,js,output (expected behavior)

Best wishes,
Tobias

Replies

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    See this thread with the same question. @allan will need to comment.

    Kevin

  • TobiasBgTobiasBg Posts: 13Questions: 1Answers: 0

    Hi!

    Thanks @kthorngren! Yes, this seems to be a very similar problem.

    @allan, do you have an opinion on this?
    For me, it clearly a bug, as simply defining different data for the sorting should not influence the actual column.
    (The use case for this is a column with highly complex data (e.g. images, complex HTML, ...) for which a custom sorting algorithm isn't feasible. Then, the hidden orderData column will e.g. have plain numbers that are instead used for the sorting of the complex column. This has been working well, but DT2 is now adding the sorting arrow icons to the wrong column.)

    Best wishes,
    Tobias

  • allanallan Posts: 63,676Questions: 1Answers: 10,497 Site admin

    Yup, I can certainly see that argument. When implementing it (if I recall correctly) I was primarily thinking about multi-column sorting - when triggering ordering on one column would have the table ordered on that column plus another - in such a case it would be appropriate to implement it as it currently is.

    But for ordering based on data from another column completely, as is your case here, then that isn't all that useful.

    In retrospect perhaps it would have been better to do it the way discussed here. I'll look into what is involved in making that change.

    Allan

  • TobiasBgTobiasBg Posts: 13Questions: 1Answers: 0

    Hi @allan,

    Thanks for your insights here!

    When implementing it (if I recall correctly) I was primarily thinking about multi column sorting - when triggering ordering on one column would have the table ordered on that column plus another

    Now, even for this, it seems strange that the original column (which is the one where the column header is clicked), doesn't have sorting arrow icons, no?

    I'll look into what is involved in making that change.

    Thanks, that would be great! As this used to work fine before, it would be great to keep that old behavior.

    Best wishes,
    Tobias

  • allanallan Posts: 63,676Questions: 1Answers: 10,497 Site admin

    Agreed - something not quite right there. To be looked at! Working on Editor 2.4 at the moment and then DataTables 2.2, which this will be part of.

    Allan

Sign In or Register to comment.