Column Sorting

The Ignite UI for React Data Table / Data Grid supports ascending and descending column sorting with a Single Column, Multi-Column and Tri-State Column Sorting configuration.

Demo

Code Snippet

You can sort by a single or multiple column ascending or descending in the React data grid by using the headerClickAction property. If TriState is enabled you can remove the sort applied to a column.

import { HeaderClickAction } from "igniteui-react-grids/ES5/HeaderClickAction";
<IgrLiveGrid
    height="100%"
    width="100%"
    headerClickAction={HeaderClickAction.SortByMultipleColumns}
    dataSource={this.data}
    ref={this.onGridRef}/>

Sorting through API

import { ColumnSortDescription } from "igniteui-react-grids/ES5/igr-column-sort-description";
import { ListSortDirection } from "igniteui-react-core/ES5/ListSortDirection";
public onGridRef(grid: IgrLiveGrid) {
    this.grid = grid;
}
// ...
let colSortDesc = new ColumnSortDescription();
colSortDesc.propertyPath = "UnitsInStock";
colSortDesc.sortDirection = ListSortDirection.Descending;
this.grid.sortDescriptions.add(colSortDesc);