DxDataGridColumn.SortIndex Property

Specifies the column’s index among sorted columns. If the property is set to -1, the grid data is not sorted by this column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
[DefaultValue(-1)]
public int SortIndex { get; set; }

Property Value

Type Default Description
Int32

-1

Specifies the zero-based column’s index among sorted columns. -1 if the grid does not sort data by this column.

Remarks

Set a column’s SortIndex property to a zero-based integer value to sort grid data by this column in code. If you sort data by multiple columns, this property specifies the sort level. For instance, the grid first sorts data by a column with SortIndex = 0 and then by a column with SortIndex = 1.

Use the SortOrder property to specify the sort order (the default order is ascending).

NOTE

If you do not specify these properties, the Data Grid is sorted by a data source field that is marked with the Key attribute. If the data source does not contain a key field, component data is not sorted.

<DxDataGrid Data="@DataSource">
    <DxDataGridColumn Field="@nameof(ProductFlat.Category)"
                      SortOrder="DataGridColumnSortOrder.Descending" 
                      SortIndex="0">
    </DxDataGridColumn>
    <DxDataGridColumn Field="@nameof(ProductFlat.Subcategory)"
                      SortOrder="DataGridColumnSortOrder.Ascending"
                      SortIndex="1">
    </DxDataGridColumn>
    ...
</DxDataGrid>

DataGrid Sort

If you set the column’s SortIndex property to a negative integer value (for instance, -1), the grid is not sorted by the corresponding column.

Online Demo

Data Grid - Sort Data

See Also