Blazor DataGrid Example - Multi-Column Sorting
This example shows how to use the DataGrid's multi sorting feature. Hold down the Ctrl key and click the column header to sort two or more columns.
| Order IDPress Enter to sort | 1Customer IDSorted in ascending order | 2 Order DateSorted in descending order | FreightPress Enter to sort | 
|---|
| 10001 | ALFKI | 5/15/1991 | $2.30 | 
| 10006 | ALFKI | 5/15/1991 | $4.60 | 
| 10011 | ALFKI | 5/15/1991 | $6.90 | 
| 10016 | ALFKI | 5/15/1991 | $9.20 | 
| 10021 | ALFKI | 5/15/1991 | $11.50 | 
| 10026 | ALFKI | 5/15/1991 | $13.80 | 
| 10031 | ALFKI | 5/15/1991 | $16.10 | 
| 10036 | ALFKI | 5/15/1991 | $18.40 | 
| 10041 | ALFKI | 5/15/1991 | $20.70 | 
| 10046 | ALFKI | 5/15/1991 | $23.00 | 
| 10051 | ALFKI | 5/15/1991 | $25.30 | 
| 10056 | ALFKI | 5/15/1991 | $27.60 | 
The sorting feature of the Blazor DataGrid allows us to order the data in a specific direction. Set the AllowSorting property to true to enable it. Simply click the column header to sort a DataGrid column.
Multi-sorting is enabled by default in DataGrid; to sort multiple columns, hold down the Ctrl key and click the column header. Hold the Shift key and click the column header to clear sorting for that column.
To sort a specific column in this demo, simply click the column header.
More information about the Multi sorting feature can be found in this documentation section.