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

GridColumnSortOrder Enum

Lists values that specify a column’s sort order.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public enum GridColumnSortOrder

Members

Name Description
None

Sorting is not applied.

Ascending

Sorts data in ascending order.

Descending

Sorts data in descending order.

Related API Members

The following properties accept/return GridColumnSortOrder values:

Remarks

Use the SortOrder property to specify a column’s 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})";
        }
    }
}

Run Demo: Grid - Sort Data

See Also