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

expand TreeViewList

6 Answers 278 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
KK
Top achievements
Rank 1
KK asked on 31 Dec 2010, 07:46 AM
Hello,
I am using TreeviewList in my WPF appication using MVVM. I want to show all nodes in expanded mode but by default it shows me only parent node. Is there any way to show all nodes (in expanded mode) automatically?

6 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 31 Dec 2010, 10:00 AM
Hi KK,

I suggest you check the following help article that should get you started:
http://www.telerik.com/help/wpf/treelistview-expand-all-hierarchy.html

Hope this helps.

All the best,
Nick
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Cheau-Long
Top achievements
Rank 1
answered on 11 Mar 2011, 11:28 PM
Hi Telerik,

I have a similar question in expanding the tree. I followed the example and was able to expand the tree when View was first initialized. However, if the entire collection was changed, I wasn't able to fire the event to expand the tree. I'm using MVVM model. The collection was implemented as ObservableCollection. I have to re-create the view in order to fire the event. Is there a event in TreeViewList when the data is completed?

       public PipeSegmentView()
        {
           this.pipeTreeListView.DataLoaded += new EventHandler<EventArgs>(pipeTreeListView_DataLoaded);
        }
 
        private void pipeTreeListView_DataLoaded(object sender, EventArgs e)
        {
            this.pipeTreeListView.DataLoaded -= new EventHandler<EventArgs>(pipeTreeListView_DataLoaded);
            this.pipeTreeListView.ExpandAllHierarchyItems();
        }        
0
Maya
Telerik team
answered on 12 Mar 2011, 04:51 PM
Hello Cheau-Long,

I have tried to reproduce the issue you reported, but I was not able to. I am sending you the sample project I used for the test. Please take a look at it and let me know in case of any misunderstandings.

 

Best wishes,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Cheau-Long
Top achievements
Rank 1
answered on 14 Mar 2011, 06:03 PM
Hi Maya,

Thanks for the quick response! The DataLoad event worked just fine to expand the tree, I actually referred to how to re-expand the tree if the datasource was reloaded with a different set of data. Please find the attached modification of your example. In the example, you will see "Refresh Data" button, which will fetch a different tree-like data (GetClubs2). Because the DataLoaded event was removed after the data was loaded, the event won't be fired again. I tried to take keep this event, but error occurred when the entire datasource was updated.
		void RadTreeListView1_DataLoaded(object sender, EventArgs e)
		{
			this.RadTreeListView1.DataLoaded -= new EventHandler<EventArgs>(RadTreeListView1_DataLoaded);
			this.RadTreeListView1.ExpandAllHierarchyItems();   
		}

My question is how to re-trigger this event, if the data model is updated. I have a RoutedCommand that will update the datasource in the VM, and not using the codebehind as I did in the example.

Thanks for helping!
Cheau-Long
0
Maya
Telerik team
answered on 15 Mar 2011, 02:09 PM
Hello Cheau-Long,

Generally, the idea behind calling the ExpandAllHierarchyItem() method in the DataLoaded event is that you need to make sure all the elements are loaded as well as the items themselves. 
You mentioned that you updated the sample project I attached previously, but unfortunately I am not able to see any files attached. May you try to resend it so that I can see your exact requirements ? 
Basically, I have tested the sample by handling a Click event of a button, changing the ItemsSource there and calling that very method. However, it all works appropriately and the parent rows are expanded. Is that the scenario you tried ? 

 

All the best,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Mark
Top achievements
Rank 1
answered on 12 Sep 2011, 06:18 PM
Hi Cheau-Long,

I am faced with this challenge as well.  Did you manage to find a suitable solution? 

Thanks,
Mark
Tags
TreeListView
Asked by
KK
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Cheau-Long
Top achievements
Rank 1
Maya
Telerik team
Mark
Top achievements
Rank 1
Share this question
or