This is a migrated thread and some comments may be shown as answers.

Filtering opens All the Nodes

3 Answers 160 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
gans
Top achievements
Rank 1
gans asked on 18 Jun 2013, 11:42 PM
Sorry - This is supposed to posted  under TreeListView and not TreeView. I will try to repost under TreeListView.

I have a problem where after applying the Filter, it opens up all the nodes.

I am using CompositeFilterDescriptor.

We have a Huge Tree and we don't want the Tree and its children  to open after applying the Filter. Any idea how to stop it from opening after applying the Filter?

I am not able to attach the project, but will attach the screen shot. 

Here is code snippet. 

private void RadContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if ((e.OriginalSource as RadMenuItem).Header.Equals("Show Spain"))
            {
                FilterDescriptor descriptor = new FilterDescriptor();
                descriptor.Member = "Country";
                descriptor.Operator = FilterOperator.IsEqualTo;
                descriptor.Value = "Spain";
                this.RadTreeListView1.FilterDescriptors.Add(descriptor);
            }
 
            CompositeFilterDescriptor mainFilter = new CompositeFilterDescriptor();
 
            if ((e.OriginalSource as RadMenuItem).Header.Equals("Show England"))
            {
                FilterDescriptor descriptor = new FilterDescriptor();
                descriptor.Member = "Country";
                descriptor.Operator = FilterOperator.IsEqualTo;
                descriptor.Value = "England";
                mainFilter.FilterDescriptors.Add(descriptor);
                this.RadTreeListView1.FilterDescriptors.Add(mainFilter);
            }
            if ((e.OriginalSource as RadMenuItem).Header.Equals("Show England - France"))
            {
                mainFilter = new CompositeFilterDescriptor();
                mainFilter.LogicalOperator = FilterCompositionLogicalOperator.Or;
                FilterDescriptor descriptor = new FilterDescriptor();
                descriptor.Member = "Country";
                descriptor.Operator = FilterOperator.IsEqualTo;
                descriptor.Value = "England";
 
                mainFilter.FilterDescriptors.Add(descriptor);
                descriptor = new FilterDescriptor();
                descriptor.Member = "Country";
                descriptor.Operator = FilterOperator.IsEqualTo;
                descriptor.Value = "France";
 
                mainFilter.FilterDescriptors.Add(descriptor);
 
                this.RadTreeListView1.FilterDescriptors.Add(mainFilter);
            }
 
            if ((e.OriginalSource as RadMenuItem).Header.Equals("Clear Filter"))
            {
                this.RadTreeListView1.FilterDescriptors.RemoveAt(0);
            }
             
        }

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 21 Jun 2013, 09:12 AM
Hello,

Expanding the rows when filtering is the behavior by design and currently it cannot be changed. I am afraid that there is not a setting to configure it.
 

Regards,
Didie
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Neil
Top achievements
Rank 1
answered on 09 Sep 2014, 08:28 PM
Has this behavior been changed yet?  It seems helpful to expand the tree to display children nodes that meet the filter criteria sometimes, but I would like to hide an entire row based on a visibility flag in my ViewModel.  While the filter functions correctly, expanding all the other nodes is inconvenient at best; with a large data set, this can be very problematic.

It would be nice to execute a filter with an optional bool flag to AutoExpandResults after the execution.  I've tried to capture the filter event and collapse manually, but the Filtered event doesn't seem to fire on a filter I create and run in code behind.

Any help would be appreciated.

0
Dimitrina
Telerik team
answered on 12 Sep 2014, 02:52 PM
Hello,

I am afraid we have not changed the behavior of RadTreeListView on filtering.

As to the filtering events, those events are raised only based on user interaction, when the end-user is using the UI to filter. In case you are working with the filters in code, you are the one adding filtering and thus you could take any respective actions you wish. 
You can also try executing your code in a Dispatcher.

Regards,
Dimitrina
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TreeView
Asked by
gans
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Neil
Top achievements
Rank 1
Share this question
or