Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxGrid.ClearFilter() Method

Clears the filter applied to grid data.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
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();
    }
}

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

Razor
<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