The sort API interface that is available in the grid [[apiRef]].

interface GridSortApi {
    applySorting: (() => void);
    getRowIdFromRowIndex: ((index: number) => GridRowId);
    getSortedRowIds: (() => GridRowId[]);
    getSortedRows: (() => GridValidRowModel[]);
    getSortModel: (() => GridSortModel);
    setSortModel: ((model: GridSortModel) => void);
    sortColumn: ((field: string, direction?: GridSortDirection, allowMultipleSorting?: boolean) => void);
}

Hierarchy (view full)

Properties

applySorting: (() => void)

Applies the current sort model to the rows.

getRowIdFromRowIndex: ((index: number) => GridRowId)

Gets the GridRowId of a row at a specific index. The index is based on the sorted but unfiltered row list.

Type declaration

    • (index): GridRowId
    • Parameters

      • index: number

        The index of the row

      Returns GridRowId

      The GridRowId of the row.

getSortedRowIds: (() => GridRowId[])

Returns all row ids sorted according to the active sort model.

Type declaration

getSortedRows: (() => GridValidRowModel[])

Returns all rows sorted according to the active sort model.

Type declaration

getSortModel: (() => GridSortModel)

Returns the sort model currently applied to the grid.

Type declaration

setSortModel: ((model: GridSortModel) => void)

Updates the sort model and triggers the sorting of rows.

Type declaration

    • (model): void
    • Parameters

      Returns void

sortColumn: ((field: string, direction?: GridSortDirection, allowMultipleSorting?: boolean) => void)

Sorts a column.

Type declaration

    • (field, direction?, allowMultipleSorting?): void
    • Parameters

      • field: string

        The field identifier of the column to be sorted.

      • Optionaldirection: GridSortDirection

        The direction to be sorted. By default, the next in the sortingOrder prop.

      • OptionalallowMultipleSorting: boolean

        Whether to keep the existing [[GridSortItem]]. Default is false.

      Returns void