Sorting by two hidden columns

Sorting by two hidden columns

avioliavioli Posts: 4Questions: 0Answers: 0
edited October 2012 in General
I'm using the latest DataTables version and have a table that has one visible column (#1), that shows a range of two numbers ($%d - $%d) and two hidden columns, that actually hold the min (#2) and max (#3) ranges (both pure numbers). The visible column is only for visual, not to be used to sort by.

I would like to sort first by min (asc, then desc) and then by max (asc, desc), which means that after four clicks on the visible's column heading the sorting resets from min again. Here's the sequence: no-sort, (click) min-asc, (click) min-desc, (click) max-asc, (click) max-desc, (click) min-asc... I don't want to worry at the moment for Shift-clicks.

I tried iDataSort: 2 (or 3), and that works fine, but only sorts by one column, even though it is hidden.

Tried asSorting: ['asc','desc','asc','desc'], but that doesn't change the sequence actually or by which column to sort by.

Tried aDataSort: [2,3], but that is the same as to use the visible column... kind of concatenates the two columns and sorts like that. Tried even [2,3,3,2], even though I knew it won't work, hehe.

The last resort that works is by using sSortDataType and extending afnSortData with a custom sort type. It works, but looks messy. Is there a better way, that I'm not aware of?

And last - how can I get the sort direction? I want to replace the heading text for the visual range accordingly.

Replies

This discussion has been closed.