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 Filter a record in the GridTreeControl?

Platform: WPF |
Control: GridTreeControl
Tags: filtering

The GridTreeControl does not provide direct support to filter a record. To filter a record, you can use the Filter predicate in the ICollectionView. By using the ICollectionView type as itemssource to the GridTreeControl, you can filter the records in the ICollectionView. So, the records that satisfy the given condition will be displayed in the GridTreeControl.

You can refer to the following code example to use the ICollectionView.



Here, the GetDefaultView method returns the default view of the given source and the PersonDetails is the source (that is the observable collection and having the person details displayed in the Grid).

You can refer to the following code example to define the GridTreeControl in XAML.



Records in the GridTreeControl can be filtered with the help of the Filter Predicate in the ICollectionView. Refer to the following code example to filter the record by using the Filter Predicate.



In the following screenshot, the default view of the Grid is displayed.

Figure 1: Default view of grid

The following screenshot displays the entered text (“Blue”) in the textbox is filtered in the Grid.

Figure 2: Entered text filtered in a grid

You can filter the Grid by entering the text in the search textbox. On clicking the ApplyFilter button, the FilterValueMethod command in the viewmodel is invoked. In this command, the CollectionView is refreshed by using the Refresh method and while refreshing the CollectionView, the Filter Predicate is fired and the records are filtered based on the FilterString that holds the text in the search textbox. Finally, the GridTreeControl is redrawn by using the ResetDisplay method.

You can refer to the following code example to call the Refresh method in the CollectionView and ResetDisplay method in the GridTreeControl.



You can refer to the following sample links to filter a records in GridTreeControl for WPF platforms.

Sample Link: FilteringRecordsinGTC_WPF

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment
Antoine Farine
Nov 04, 2016
This solution filters only the first level records, but the GridTree purpose is to have multiple levels. Is it possible to filter a collection's SubItems? Reply

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