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.

How to Filter a record in the GridTreeControl?

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.

C#

 

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.

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.

C#

 

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.

C#

 

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

Sample Link: FilteringRecordsinGTC_WPF

Article ID: Published Date: Last Revised Date: Platform: Control:
4515 04/19/2015 07/10/2015 WPF GridTreeControl
Tags:
Did you find this information helpful?
Comments
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
Add Comment
You must log in to leave a comment

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.