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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to clear the filtering for all columns using HeaderContextMenu?

Filters applied to SfDataGrid can be cleared by calling SfDataGrid.ClearFilters. As the requirement is to clear filter using HeaderContextMenu, define ContextMenu for Header using SfDataGrid.HeaderContextMenu property. In the following XAML code, the ContextMenu is defined with one MenuItem for HeaderContextMenu.

XAML

The Command property in MenuItem is bound with the ContextMenuCommand.ClearFiltering command that is defined in the code example. The following code example is for ContextMenuCommands static class with ClearFiltering command property in it. MenuItem in HeaderContextMenu gets the GridColumnContextMenuInfo as command parameter, when the action is triggered. GridColumnContextMenuInfo has the following properties, from which you can clear the filters for particular column or for the all GridColumns.

  • Column – It contains GridColumn
  • DataGrid – It contains SfDataGrid

In the following ClearFiltering action, the filters are cleared for all columns by using SfDataGrid.ClearFilters() method.

C#

Now, you can see ContexMenu when you right click on the column header of SfDataGrid, as in the following screenshot.

F:\Issuesample\WPF-14972 clear filter\finalfilter.png

You can refer the sample from the following location,

WPF: ClearFilterforallColumn_WPF

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
2506 08/14/2014 07/03/2015 WPF SfDataGrid 4.5
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon