DxDataGridColumn.AllowSort Property

Specifies whether users can sort data by the column’s values.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[DefaultValue(null)]
[Parameter]
public bool? AllowSort { get; set; }

Property Value

Type Default Description
Nullable<Boolean>

null

true if users can sort data by the column’s values; otherwise, false.

Remarks

Users can click a column header to sort grid data by this column. To change the sort order, users should click the column header once again. To sort grid data by multiple columns, users should click column headers with the Shift key pressed.

DataGrid Sort

A column’s AllowSort property allows you to enable/disable sorting data by individual columns. If this property is set to NULL, the data grid’s AllowSort property defines the column’s behavior.

The following example demonstrates how to disable sorting by the ID column (set the column’s AllowSort property to false).

<DxDataGrid Data="@DataSource">
    <DxDataGridColumn Field="@nameof(ProductFlat.Id)" AllowSort="false" >
    </DxDataGridColumn>
    ...
</DxDataGrid>

The following example demonstrates how to disable sorting in the entire grid (set the data grid’s AllowSort property to false), but enable sorting by the ID column (set the column’s AllowSort property to true).

<DxDataGrid Data="@DataSource" AllowSort="false">
    <DxDataGridColumn Field="@nameof(ProductFlat.Id)" AllowSort="true">
    </DxDataGridColumn>
    ...
</DxDataGrid>
NOTE

You can use the column’s SortIndex property to sort data in code regardless of the AllowSort property value.

Online Demo

Data Grid - Sort Data

See Also