DeeboData JS Grid Angular Grid React Grid
Contact Us Demo Pricing

DeeboData Review Code for: Sorting By Multiple Columns

* You can sort by multiple columns at the same time with priority!
The sorting functionality works out of the box. Strings are sorted alphabetically, numbers numerically, and dates chronologically. To review the code making this happen, search your code base for nLevelSort and doSortOnField. These are the respective functions where the sorting logic is executed for each column and where you can customize the sorting logic if you like.


Have a look below at the javascript quick start's running sample code you can set up in minutes. Notice that "Salary" takes priority over "Title" because it was clicked first. Hence the 1 beside the column name. The "Title" column has a 2 in the column header and will be sorted only if "Salary" values are the same. Further down, see what happens when "Title" is sorted descending while "Salary" is still sorted ascending.

Multi column sorting example
The data grid will always keep track of your sorts and filters in the footer.





Now look at the grid when the "Title" column is sorted descending. The arrow will point upwards, and notice that Adam and Amy now have switched their order in the grid. Since they have the same salary, the "Title" column is used to determine their order:

Descending sort example