After any column sort make a secondary sort with another column every-time

After any column sort make a secondary sort with another column every-time

djnzjaindjnzjain Posts: 1Questions: 1Answers: 0

Let's say we have 5 columns in data-table.
First Name
Last Name
Age
Salary
Type of Member (Category as in A,B,C etc.,)

After any column sort Type of Member column should be sorted,

For example if the user is sorting lets say by Last Name, after last name sort, Type of Member should be sorted so that first we see the data for Members with Type A and then B etc.

Lets say data-table has 7 rows, if the user is sorting with Last Name desc and post sort it will display as

1st Row - Type "A"
2nd Row - Type "B"
3rd Row - Type "A"
4th Row - Type "B"
5th Row - Type "B"
6th Row - Type "B"
7th Row - Type "A"

but i need to do a secondary sort on Type of Member Column after last name sort

1st Row - Type "A"
2nd Row - Type "A"
3rd Row - Type "A"
4th Row - Type "B"
5th Row - Type "B"
6th Row - Type "B"
7th Row - Type "B"

Is this possible only via custom sort or can we use any existing methods or functions of Datatables?

This question has an accepted answers - jump to answer

Answers

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

    You can use orderFixed for that - see here - it's always applying an additional order to the age column.

    Colin

This discussion has been closed.