Disable Sort on just one column meanwhile the other are orderable

Disable Sort on just one column meanwhile the other are orderable

Luca4k4Luca4k4 Posts: 9Questions: 3Answers: 0

For example:

1 B
2 A
3 C

I want to be able to sort the second column but the first should remain in the same position ignoring the sort. In the above example, sorting the second column ascending:

1 A
2 B
3 C

Or descending:

1 C
2 B
3 A

The first column always remains in 1->2->3 order. How can i realize that?

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @Luca4k4 ,

    A row is an entity, with each cell being part of that row. If I understand correctly, you want to 'break' the row, by displaying cells from different rows alongside each other. That doesn't follow the model of row-based operations, I'm afraid, so, no, that's not supported.

    Cheers,

    Colin

  • Luca4k4Luca4k4 Posts: 9Questions: 3Answers: 0
    edited April 2018

    Hi,
    thank you for the answer. Yes i would like to "break" the row association. I need that because i want to make a "rank" column # (1, 2, 3..). Sad to know i can't do it.

    Anyway thank you very much! Have a nice Sunday

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916

    @Luca4k4, As Colin said its not a built-in feature of Datatables. However you could write some Javascript to keep the first column in the order you want by looping through the rows and re-writing the values in the first column. You could take advantage of one of the Datatables Events or Call Backs.

    I would probably use rowCallback since it processes on the rows displayed and the page.info() api to determine the page offset for the first value.

    Kevin

This discussion has been closed.