Skip to main content

DxGrid.ClearFilter() Method

Clears the filter applied to grid data.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public void ClearFilter()

Remarks

The Grid applies a filter if any of the following includes filter conditions:

Call the ClearFilter method to clear all filter conditions.

The highlighted code block adds a button that clears filter conditions.

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

<DxGrid Data="@Data"
        ShowFilterRow="true"
        @ref="MyGrid">
    <Columns>
        <DxGridDataColumn FieldName="OrderId" Caption="Order ID" DisplayFormat="d" />
        <DxGridDataColumn FieldName="OrderDate" DisplayFormat="d" />
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c2" />
        <DxGridDataColumn FieldName="Shipped" UnboundType="GridUnboundColumnType.Boolean"
                          UnboundExpression="[ShippedDate] <> Null" />
    </Columns>
</DxGrid>

<DxButton Click="@(() => MyGrid.ClearFilter())">Clear Filter</DxButton>

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

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = Northwind.Invoices
            .ToList();
    }

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

Grid - Clear Filter in Code

To clear a filter condition for an individual column in code, call the FilterBy method and pass null to its value parameter.

<DxButton Click="@(() => MyGrid.FilterBy("ProductName", GridFilterRowOperatorType.Contains, null))">Clear the "Product Name" Filter Condition</DxButton>

Users can clear a filter condition in the filter row.

Implements

See Also