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

DxGrid.GetSortedColumns() Method

Gets the collection of sorted columns.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public IReadOnlyList<IGridDataColumn> GetSortedColumns()

Returns

Type Description
IReadOnlyList<IGridDataColumn>

The collection of sorted columns.

Remarks

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

<DxGrid Data="GridDataSource"
        @ref="MyGrid">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate"
                          DisplayFormat="d"/>
        <DxGridDataColumn FieldName="ShipName" />
        <DxGridDataColumn FieldName="ShipCity" />
        <DxGridDataColumn FieldName="Freight"
                          DisplayFormat="n2"
                          SortIndex="0"/>
    </Columns>
</DxGrid>

<DxButton Click="@OnGetSortedColumns">Get First Sorted Column</DxButton>
@Alert

@code {
    IGrid MyGrid { get; set; }
    object GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }
    string Alert { get; set; }

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

    void OnGetSortedColumns() {
        string FirstSortedColumnName = MyGrid.GetSortedColumns().FirstOrDefault()?.FieldName;
        Alert = "The first sorted column is " + FirstSortedColumnName;
    }

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

Grid - Get First Sorted Column

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

Implements

See Also