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

Checking/unchecking a tree node doesn't check/uncheck its child nodes automatically?

6 Answers 271 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Arpit
Top achievements
Rank 1
Arpit asked on 29 May 2011, 03:44 PM
Hi,
I am using a treeview in tri state mode. Initially the treeview is is collapsed mode. When I click and check on a collapsed parent node, its child nodes never gets checked automatically.
Once the parent node is expanded (and even if its collapsed then) and I check this node, its children are checked properly.

My requirement is to have all the nodes initially collapsed to parent level, when I check/uncheck a parent node, the node should expand and its children should get checked automatically.

Here is my markup for the treeview
<telerikNavigation:RadTreeView  Grid.Column="0" Grid.Row="0" x:Name="rdTreeView" ItemsOptionListType="CheckList" DockPanel.Dock="Bottom"
                    IsOptionElementsEnabled="True" IsRootLinesEnabled="True"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                    IsTriStateMode="True" Telerik:StyleManager.Theme="Office_Blue"
                    IsLineEnabled="True" IsEditable="True" Background="White" Margin="0,0,0,0" SelectionMode="Single"
                    IsExpandOnSingleClickEnabled="True" IsExpandOnDblClickEnabled="False"
                   BringIntoViewMode="HeaderAndItems" ItemContainerStyle="{StaticResource ItemContainerStyle}"
                    IsLoadOnDemandEnabled="False" IsVirtualizing="True"  telerikTreeView:TreeViewPanel.VirtualizationMode="Hierarchical"
                    Checked="rdTreeView_Checked" Unchecked="rdTreeView_Unchecked">
                    </telerikNavigation:RadTreeView>


Is there something I am missing? Please help.

Thanks

6 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 01 Jun 2011, 04:10 PM
Hello Arpit,

From the code snippet you sent I am not sure whether you bind the RadTreeViewItem.IsChecked or RadTreeViewItem.CheckState property. If you do, then you need to keep in mind that in binding scenarios the binding takes precedence over the TriState logic. This means that if the RadTreeViewItem.IsChecked/CheckState property binding sets the IsChecked/CheckState property to false/Off, the RadTreeView TriState logic won't change the value set by the binding.

If this is your case, it would be better to implement a custom TriState logic in your view models. I attached a sample application demonstrating a possible approach towards such scenario.

Greetings,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Arpit
Top achievements
Rank 1
answered on 03 Jun 2011, 07:07 AM
I am using CheckedState property of the treeview nodes. The children nodes get checked/unchecked if they are expanded (it means if they are in view) not other wise.
<Style TargetType="{x:Type telerikNavigation:RadTreeViewItem}" x:Key="ItemContainerStyle">
                <Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}"/>
                <Setter Property="CheckState" Value="{Binding Path=ToggleState, Mode=TwoWay}"/>
            </Style>
0
Arpit
Top achievements
Rank 1
answered on 03 Jun 2011, 07:26 AM
This is urgent for me, if somebody can respond quickly on this, it will be a great help.
0
Tina Stancheva
Telerik team
answered on 03 Jun 2011, 09:05 AM
Hi Arpit,

Thank you for the clarification. Indeed when you bind the CheckState property of the RadTreeViewItems the TriStateMode of the RadTreeView control won't work since the binding has a higher priority. That means that if you initially set all RadTreeViewItems CheckState to Off, then even if the RadTreeView.TriStateMode is turned on and you check a parent, this will only change the value of the parent's ToggleState business property, however since the binding logic is with a higher priority, this action will not trigger any changes in the ToggleState business properties of the parent's children collection.

This is a design decision in the RadTreeView control since when you bind the RadTreeView control states, then the ViewModel should control them and letting the RadTreeView.TriStateMode change the ViewModel properties might cause many issues. This is why above (TreeViewCustomTriState.zip) I attached a sample project that demonstrates how to implement a tri-state logic in the ViewModel. Please examine the project and let me know if it helps.

Greetings,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Arpit
Top achievements
Rank 1
answered on 03 Jun 2011, 07:58 PM
Thanks for the response Tina,

I am not using view model pattern in my application, so couldn't use the solution you sent. Another problem I am facing is PreviewChecked and PreviewUnchecked events of tree run multiple time for e.IsUserInitiated == true for the same node.

These issues are really disappointing at this moment.
0
Tina Stancheva
Telerik team
answered on 08 Jun 2011, 02:57 PM
Hi Arpit,

I am really sorry to hear about your frustration and I want to assure you that we want to facilitate your efforts when using the RadTreeView control in your scenario. However, I am not sure that I understand the specifications of your scenario. Can you please send us a sample project illustrating your scenario and requirements so that we can look into it and provide you with a better solution for your issues.

Also, I wasn't able to reproduce the PreviewChecked and PreviewUnchecked events issue you reproted so a sample project will also help us investigate that case as well.

Thank you in advance for your understanding and cooperation.

Best wishes,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Arpit
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Arpit
Top achievements
Rank 1
Share this question
or