5
votes

I'm using a RadDataFilter to filter ItemSource of the RadTreeView, but when this code is exercised the filter only applies to the Root nodes which is insufficient. Is there a way to make the filter trickle down in the hierarchy of nodes so that my predicate is called for every node? In other words, can the filter be applied to the TreeView as a whole?

The RadDataFilter: the Source is binding to an ObservableCollection in the ViewModel.

<telerik:RadDataFilter Name="radDataFilter"
                           telerik:StyleManager.Theme="Metro"
                           Grid.Row="2"
                           VerticalAlignment="Top"
                           HorizontalAlignment="Center"
                           MaxHeight="250"
                           Width="500"
                           BorderBrush="SkyBlue"
                           BorderThickness="2"                     
                           Source="{Binding SampleCollection}"
                           Margin="1" />
the RadTreeView:
 <telerik:RadTreeView  x:Name="RadTreeView1"
                                 VerticalAlignment="Top"
                                 HorizontalAlignment="Stretch"
                                 Grid.Row="1"
                                 ToolBar.OverflowMode="Always"
                                 BorderBrush="SkyBlue"
                                 BorderThickness="2"
                                 MinHeight="300"
                                 MaxHeight="500"
                                 MinWidth="500"
                                 telerik:StyleManager.Theme="Metro"
                                 ItemsSource="{Binding FilteredSource,ElementName=radDataFilter}">
        >
        <telerik:RadTreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Children,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                <TextBlock x:Name="Item" Text="{Binding SampleCode}">
                </TextBlock>
                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsDescribed, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Value="true">
                        <Setter TargetName="Item" Property="Foreground" Value="Red"/>
                    </DataTrigger>
                </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>
        </telerik:RadTreeView.ItemTemplate>
    </telerik:RadTreeView>

I have known that Filter is a property (not a DP) of ItemsCollection which is not DependencyObject and so DP Value inheritance isn't there. Each node in the tree has its own ItemsCollection which has its own Filter. How can I set every Node's Filter?

1
Can you use the LoadOnDemand functionality then apply your filter to every child as it gets added to the tree? This theoretically should enhance the performance, especially if your datasets are going to grow to be large.B L
you should ask this question to telerik. I mean in telerik forums. They probably have an answer.Cagatay

1 Answers

0
votes

I recommend using the NodeDataBound event, which is fired for each individual node (regardless of hierarchical level). This way you can completely control what filtering you want to do to the node.

protected void RadTreeView1_NodeDataBound(object sender, RadTreeNodeEventArgs e) 
{     
    e.Node.ToolTip = (e.Node.DataItem as DataRowView)["Description"].ToString(); 
}

http://www.telerik.com/help/aspnet-ajax/treeview-server-node-databound.html