Filtering SfTreeGrid Items Before Displaying It

Hi,


I have a SfTreeGrid and I want to filter the items it displays based on some condition BEFORE displaying the SfDataGrid.

The problem is, I cannot assign the filtering predicate delegate as shown in the documentation (Filtering in WPF TreeGrid control | Syncfusion) because at that moment the SfTreeGrid.View property returns null.

How can I achieve that?


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team June 6, 2023 02:52 PM UTC

Hi Alexander Tashkov,

We have checked the reported scenario from our end. The reported problem occurs due to accessing the view filter before it's created completely in SfTreeGrid. 

However, you can overcome this by accessing the view after it's created using the Loaded event. Refer to the below code snippet,

//Event subscription

treeGrid.Loaded += OnLoaded;

 

// Event customization

private void OnLoaded(object sender, RoutedEventArgs e)

{  

    // Set the Filter predicate

    treeGrid.View.Filter = FilerNodes;

    treeGrid.View.RefreshFilter();

}


API Link: View

Note: The view will be created after assigning the ItemsSource in SfTreeGrid.

Find the sample demo in the attachment.

Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: SfTreeGridDemo_13455591.zip

Loader.
Up arrow icon