Grid Sorting

In Ignite UI for React, Sorting is enabled on the grid level.

Demo

Setting Sorting Type

You can sort by a single or multiple column ascending or descending. If TriState is enabled you can remove the sort applied to a column.

  • SortByMultipleColumns
  • SortByMultipleColumnsTriState
  • SortByOneColumnOnly
  • SortByOneColumnOnlyTriState
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);