We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Clear all filters

Hi,
is there a way how user can easily clear all filters?
The best solution would be to have new button displayed in GridRowHeaderIndentCell when some filter is set. Clicking it would clear all filters.
Is there a way how to do it?

Thanks
Ondra

1 Reply

DB Dinesh Babu Yadav Syncfusion Team May 17, 2019 07:35 AM UTC

Hi Ondra,             
 
Thanks for using Syncfusion products. 
 
If you want to clear the filtering by clicking on the RowHeaderIndentCell, you can use the ControlTemplate to load the button and wire the click event to perform the clear filter action. Refer to the following code snippet, 
 
Code Snippet: 
Xaml code 
<Style TargetType="syncfusion:GridRowHeaderIndentCell"> 
    <Setter Property="Template"> 
        <Setter.Value> 
            <ControlTemplate TargetType="syncfusion:GridRowHeaderIndentCell"> 
                <Border x:Name="PART_RowHeaderCellBorder" 
                BorderBrush="{TemplateBinding BorderBrush}" 
                BorderThickness="{TemplateBinding BorderThickness}"> 
                    <Grid> 
                        <!--Load the Button to clear the filter --> 
                        <Button Content="x" Click="ClearFilter" /> 
                    </Grid> 
                </Border> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style> 
 
C#  
private void ClearFilter(object sender, RoutedEventArgs e) 
{ 
    //Clear all the filters from the SfDataGrid. 
    this.sfdatagrid.ClearFilters(); 
} 
 
 
You  can also refer to the following KB document to clear all the column filters by using the context menu, 
 
Regards, 
Dinesh Babu Yadav 
 


Loader.
Live Chat Icon For mobile
Up arrow icon