Skip to main content

DxGridDataColumn.SortOrder Property

Specifies the column’s sort order (ascending or descending).

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(GridColumnSortOrder.None)]
[Parameter]
public GridColumnSortOrder SortOrder { get; set; }

Property Value

Type Default Description
GridColumnSortOrder None

A GridColumnSortOrder enumeration value.

Available values:

Name Description
None

Grid sorts column data in ascending order.

Ascending

Grid sorts column data in ascending order.

Descending

Grid sorts column data in descending order.

Remarks

When you specify a column’s SortIndex property, the grid sorts column data in ascending order. Use the SortOrder property to change the sort order.

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

<DxGrid Data="GridDataSource">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate"
                          DisplayFormat="d"
                          SortIndex="1" />
        <DxGridDataColumn FieldName="ShipName" />
        <DxGridDataColumn FieldName="ShipCity" />
        <DxGridDataColumn FieldName="Freight"
                          DisplayFormat="n2"
                          SortIndex="0"
                          SortOrder="GridColumnSortOrder.Descending" />
    </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();
    }
}

Grid - SortOrder

Run Demo: Grid - Sort Data

Watch Video: Grid - Sort Data

For more information about data sorting in the Grid component, refer to the following topic: Sort Data in Blazor Grid.

Implements

See Also