I want to expand / collapse all hierarchy levels of a RadTreeListView in C# code.
I have multi level hierarchy items (generally 3-4 levels deep)
When I use
radTreeListView.ExpandAllHierarchyItems();
radTreeListView.CollapseAllHierarchyItems();
This only expands or collapses the first level hierarchy, the inner levels are left unchanged.
Any ideas on how to expand or collapse recursively all the way to the last level?
Thanks in Advance.
- Kumar
7 Answers, 1 is accepted
Actually, I am not able to reproduce the issue you specified. Please take a look at the sample project attached and let me know if I am missing something according to your requirements.
All the best,
Vera
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks for your reply and sample code. But this is not what I was looking for.
Let me explain using your attached example, please follow these steps:
- Run your code, this will open up the TreListView with everything collapsed
- Expand 'Drinks' node
- Expand 'Tea' node under Drinks
- Expand 'Mint' node under Tea
- Click Collapse button (Here I expect all the nodes under Drinks node including Tea and Mint to collapse)
- On clicking Collapse we see that the Drinks node has collapsed
- Expand Drinks node again and see that Tea and Mint nodes are still expanded. (this is not what I want in step 5)
I hope I am clear that when I hit the collapse button, all nodes and sub nodes till the last level should be collapsed, i.e. in this case on clicking Collapse button Drink, Tea, Mint nodes should all collapse.
Let me know if this can be done.
Regards,
Kumar
Thank you for the addtional information.
May I ask you to confirm that the version of the controls you have installed is the latest official Q2 2011?
If you use an older version I would suggest you to download Q2 2011 and everything should work properly.
I hope this helps. Let me know how it goes.
All the best,
Vera
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
With our latest official version (Q1 2012) you can use AutoExpandItems property of the treelist instead.
Kind regards,Vlad
the Telerik team
I am using the latest version of control.
Let me rephrase my question. I have 2 buttons "Expand All" and "Collapse All".
When you click on "Expand All" - i call this
radTreeListView.ExpandAllHierarchyItems();
When you click on "Collapse All" - i call this
radTreeListView.CollapseAllHierarchyItems();
I want disable each of the button based on if the "TreeListView" items are expanded or collapsed.
As I said in my previous reply you should use AutoExpandItems to achieve your goal however it seems that you've missed to try it. When you set this property to true the treelist will expand all items and when you set it to false all items will be collapsed. You can bind IsEnabled property of your buttons using IValueConverter to this boolean property.
Regards,Vlad
the Telerik team