Skip to main content
A newer version of this page is available. .

DxGrid.AllowSort Property

Specifies whether users can sort grid data.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

NuGet Package: DevExpress.Blazor

Declaration

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

Property Value

Type Default Description
Boolean true

true to allow users to sort grid data; otherwise, false.

Remarks

The DxGrid allows users to sort its data.

  • To apply sorting for one column, users can click the column header. They can click the header again to change the sort order. The sort glyph indicates the column’s current sort order.

  • To sort the Grid against multiple columns, users should click column headers with the Shift key pressed.

  • To clear sorting, users can hold the Ctrl key and click the column headers.

Sort Data

Set the AllowSort property to false to disable data sorting in the entire grid.

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="GridDataSource"
        AllowSort="false">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate"
                          DisplayFormat="d" />
        <DxGridDataColumn FieldName="ShipName" />
        <DxGridDataColumn FieldName="ShipCity" />
        <DxGridDataColumn FieldName="Freight"
                          DisplayFormat="n2" />
    </Columns>
</DxGrid>

@code {
    object GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = Northwind.Orders.ToList();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

To disable sorting by individual columns, use the DxDataGridColumn.AllowSort property.

Note

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

Run Demo: Grid - Sort Data

Watch Video: Grid - Sort Data

Implements

See Also