DxGridDataColumn.SortOrder Property

Specifies the column’s sort order.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
public GridColumnSortOrder SortOrder { get; set; }

Property Value

Type Description
GridColumnSortOrder

An enumeration value.

Available values:

Name Description
None

Sorting is not applied.

Ascending

Sorts data in ascending order.

Descending

Sorts 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
@using Grid.Northwind
@inject NorthwindContext Northwind

<DxGrid Data="GridDataSource"
        CustomizeCellDisplayText="OnCustomizeCellDisplayText">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate"
                      DisplayFormat="d"
                      SortIndex="1" />
        <DxGridDataColumn FieldName="Customer" />
        <DxGridDataColumn FieldName="Freight"
                      DisplayFormat="n2"
                      SortIndex="0"
                      SortOrder="GridColumnSortOrder.Descending" />
    </Columns>
</DxGrid>

@code {
    IGrid MyGrid;
    object GridDataSource { get; set; }

    protected override void OnInitialized() {
        GridDataSource = Northwind.Orders
            .Include(i => i.Customer)
            .Include(i => i.OrderDetails)
            .Include(i => i.ShipViaNavigation)
            .ToList();
    }

    void OnCustomizeCellDisplayText(GridCustomizeCellDisplayTextEventArgs e) {
        if (e.FieldName == "Customer") {
            var customer = (Customer)e.Value;
            e.DisplayText = $"{customer.CompanyName} ({customer.Country}, {customer.City})";
        }
    }
}

Grid - SortOrder

Run Demo: Grid - Sort Data

Implements

See Also