Skip to main content

DxGrid.ClearSort() Method

Clears sorting.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public void ClearSort()

Remarks

The ClearSort method does the following:

  • Clears sorting applied to columns.
  • Ungroups columns if grouping is applied.
@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="GridDataSource"
        @ref="MyGrid">
    <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>

<DxButton Click="@(() => MyGrid.ClearSort())">Clear Sort</DxButton>

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

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

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

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