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

How to set and apply the column filter in code behind?

Platform: WPF |
Control: GridDataControl |
Published Date: August 6, 2014 |
Last Revised Date: August 6, 2014 |
.NET Framework: 4 |
Product Version:
Tags: filtering

GridDataControl allows you to create filters and apply them from code behind in two ways,

  • Using Column filter
  • Using View filter

Column filter:

You can apply filter to a particular column by adding FilterPredicate to the Filters of that VisibleColumn using Filters.Add method.

FilterPredicate class has the following properties.







Determines the filter behavior of the predicate.



Determines the type of filter to be applied for the predicate.



Determines the filter value to be applied for the predicate.



Determines whether the predicate to be applied with the filter value is case sensitive.



Determines the relations of multiple predicates and whether they should be applied with OR or AND.


Filter Behavior

  • StringTyped: Records are filtered without considering the type and it takes all the types as string.
  • StronglyTyped: Records are filtered according to the underlying type.


Filter Type

  • Contains: Checks the records that contain the filter value.
  • EndsWith: Checks the records which end with the filter value.
  • Equals: Checks the records which are equal to the filter value.
  • GreaterThan: Checks the records which are greater than the filter value.
  • GreaterThanOrEqual: Checks the records which are greater than or equal to the filter value.
  • LessThan: Checks the records which are less than the filter value.
  • LessThanOrEqual: Checks the records which are less than or equal to the filter value.
  • NotEquals: Checks the records which are not equal to the filter value.
  • StartsWith: Checks the records which start with the filter value.
  • Between: Checks the records which have values between the filter values.


Predicate Type

  • AND: Applies AND operator between the predicates.
  • OR: Applies OR operator between the predicates.


You can set any Predicate Type and conditions available in Predicate class to a VisibleColumn’s Filter. Refer the following code example, where column filter is applied to the “Companynamecolumn with FilterType “Equals”, FilterValue Syncfusion”, and PredicateType as And”.



Following snapshots illustrates the effect of above code in GridDataControl

D:\Syncfusion\Issues\2014 Volume 2\KB Issues\KB Images\Filtering.PNG


View Filters:

GridDataControl provides support to achieve view filtering by setting the GridDataControl.Model.View.Filter property. FilterRecords method filters the data that contains the filterText value. To filter a column assign, FilterRecords method to GridDataControl.Model.View.Filter predicate. Refer the following code.



Following snapshot illustrates the effect of above code in GridDataControl


D:\Syncfusion\Issues\2014 Volume 2\KB Issues\KB Images\ViewFilter.PNG


In this example, the GridDataControl contains EmployeeDetails as ItemsSource. FilterRecords method is used to filter the filterText (filterText is the text entered in the text box in the view). FilterRecords is assigned to dataGrid.Model.View.Filter predicate to filter the “EmpName” column. Here the EmpName column is filtered using a search string “raj”.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
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.

Up arrow icon

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

Live Chat Icon For mobile