Can we get sort priority in multi column sort?

Can we get sort priority in multi column sort?

vinayakbhat87vinayakbhat87 Posts: 2Questions: 1Answers: 0

https://datatables.net/examples/basic_init/multi_col_sort.html

in the above link, when i sort multiple columns... is there any way to number the primary, secondary and tertiary sort columns.. ?

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    The priority is simply the order in the array. So [0,1] would prioritise column index 0, while [1,0] would prioritise column index 1.

    Allan

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    I think @vinayakbhat87 might mean "can we make the sort sequence visible to the user", in which case "No, but not a bad idea for the future"..... :)

  • vinayakbhat87vinayakbhat87 Posts: 2Questions: 1Answers: 0

    @tangerine is right. That is exactly what I am looking for. Is there anyway we can do that now?any hacks or hooks that I can use?

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Oh I see - sorry. In that case yes, what @tangerine says is correct. There isn't an option for that at the moment.

    You could listen for the order event and use the third parameter passed into the callback function to know what columns are being sorted upon. You could then use that information to display it however you need. Out of interest, how will you do that?

    Allan

  • Ethan.DavidsonEthan.Davidson Posts: 1Questions: 0Answers: 0

    I think the most common way to display sort priority is to include a number next to the arrow. The arrow indicates sort direction, and the number indicates precedence. For example, the first sort column would show (^1), the second would look like (^2), etc.

    A more powerful design can be seen in this SO answer, though it's probably overkill for most cases.

This discussion has been closed.