Change Sort Order based on a column's data

Change Sort Order based on a column's data

madrasmadras Posts: 4Questions: 1Answers: 0

Hello,

Say I have the following columns of data -
Group Number [column: 0],
Person ID (Numeric) [column: 1],
Date of Hire (MM/DD/YYYY format) [column: 2] and
Date of Hire for Sorting (Hidden, YYYYMMDD format) [column: 3].

I need the data to be always sorted by Group Number. For this I can use orderFixed.

Next, depending on the group number, the rest of the columns' sort order needs to be unique to the group:
- If Group Number = 20, order by [3, desc], then by [1, asc]
- If Group Number = 30, order by [3, desc], then by [1, desc]
- If Group Number = 40, order by [3, asc], then by [1, asc]

Is there a built-in option to accomplish this?

Thank you

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited October 2018

    Hi @madras ,

    I'm not too clear on how this would work - would there only ever be one group number in column 0 at any one time? If not, this wouldn't work - you can only sort the entire table, not groupings individually.

    Cheers,

    Colin

  • madrasmadras Posts: 4Questions: 1Answers: 0

    Edit: Or if there's a discussion on this forum you know of that discusses something like this, please point me to it. Thanks in advance.

  • madrasmadras Posts: 4Questions: 1Answers: 0
    edited October 2018

    Hi @colin: No, there will be multiple groups in the column. Therefore, based on that column's data, the sort options need to be applied to the remaining columns.

    (e.g.)

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @madras ,

    I understand. It's not possible though, I'm afraid. As I mentioned above, the table sorting happens table-wide - what you're looking for is the ability to sort a set of rows, but not the table as a whole.

    That said, as you're hiding the last column, you could manipulate that in columns.render. If you turned the number negative if the group is 40, then that would work. Likewise with person, you could have a duplicate hidden column where it's also turned negative.

    Hope that gives you some ideas,

    Cheers,

    Colin

  • madrasmadras Posts: 4Questions: 1Answers: 0

    Hi @colin: Thank you for the suggestions, much appreciated. I'll try them out.

This discussion has been closed.