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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to clear the filtering for all columns using HeaderContextMenu?

Platform: WPF |
Control: SfDataGrid |
Published Date: August 14, 2014 |
Last Revised Date: July 3, 2015 |
.NET Framework: 4.5

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

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

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