Sort change lines with same values

Sort change lines with same values

Mike205Mike205 Posts: 5Questions: 1Answers: 0

Link to test case: https://jsfiddle.net/4oybwm18/
Debugger code (debug.datatables.net):
Error messages shown: none
Description of problem:

I have a table with 2 columns and 2 lines.
The 2 lines have the same value in the first column.
When i sort the first column in asc, it doesn't change anaything but when i sort in desc, it changes the order of the lines.
It was not like that in previous version 1.10.*, it didn't change anything in asc or desc.

Is it possible to change this behavior?

Thanks

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 22,026Questions: 26Answers: 5,082
    edited May 26

    This note explains the behavior change. Also see this thread.

    Kevin

  • Mike205Mike205 Posts: 5Questions: 1Answers: 0

    I think the new behavior is a good think.
    I just don't understand why an order desc change the order of the data.
    The values are the same, so why is there an order applied?

    Mike

  • allanallan Posts: 64,545Questions: 1Answers: 10,668 Site admin
    Answer ✓

    With DataTables 2 it resets the ordering to the original index order on each order action, as described in the links Kevin gave. That allows the ordering to always be deterministic from that first state. But more than that, for a descending sort will with reverse the original order. Which is what you are seeing here.

    That reverse can be disabled using orderDescReverse which has a fuller description and example.

    Allan

  • allanallan Posts: 64,545Questions: 1Answers: 10,668 Site admin
    Answer ✓

    I've just spotted that page as an error - escaped HTML. I've got a fix which I'll deploy soon :).

    Allan

  • Mike205Mike205 Posts: 5Questions: 1Answers: 0

    thank you,
    the option orderDescReverse is just what i was looking for.
    (i don't know why i haven't seen it before...)

    Mike

  • allanallan Posts: 64,545Questions: 1Answers: 10,668 Site admin

    378 options listed here. Missing one is a forgeable offence ;).

    Allan

Sign In or Register to comment.