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

Root node expand problem

7 Answers 357 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Radu
Top achievements
Rank 1
Radu asked on 02 Jun 2009, 12:55 PM
Hi everyone. I have problems on expanding the root node of the treeview at start. I do not use data binding and I have about 4 hierarhical levels. In code at runtime I call the ExpandAll() for the level 0 nodes but they do not expand. If I expand the level 0 nodes afterwards in the UI I can see that all other levels below are expanded.

7 Answers, 1 is accepted

Sort by
0
Accepted
Tihomir Petkov
Telerik team
answered on 03 Jun 2009, 12:12 PM
Hello Radu,

The ExpandAll method works after the UI elements of the treeview have been generated and you are probably calling the method before that has happened. In case you declare your treeview items in XAML, you can simply set the IsExpanded property of the root item to true. Alternatively, you can listen for RadTreeView's ItemPrepared event and programatically set the prepared item's IsExpanded property to true. In the second case you will only have to do this the first time the event occurs, because the event is fired for every item that is being rendered and after you expand the root item the event will be fired for every child item.

Let me know if this helps and please do not hesitate to ask if you have further questions.

Greetings,
Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Radu
Top achievements
Rank 1
answered on 03 Jun 2009, 12:44 PM
Thanks a lot. It worked
0
Maria Im
Top achievements
Rank 1
answered on 21 Apr 2010, 09:04 PM
It's a bit like Radu's problem but mine is different. I have the treevoew and Load on demand for each items like s

1. Treatments
        2.VisitDate
                3.Documents
                3.Images
                3.FreeHandNotes
1.Treatments
       2.VisitDate
       2.VisitDate
            3.Documents
            3.Images
            3.FreehandNotes ..etc...

As of Now, the treatments load fine. then if you click on Treatment it activates the Load on Demand and displays visit date and if you click VisitDate it will display {documents, images and freehand notes). Now I want to load it initially with the treatment expanded, showing only the VisitDate like so:

1. Treatment 1
        2.VisitDate
1.Treatment 2
        2.VisitDate
1.Treatment 3
        2.VisitDate

Under the item prepared event, I put the code so that the curreent item prepared IsExpanded property is set to True. But when it displays on the screen, only the last treatment is expanded while the first 2 treatments asre still trying to load. Please help.
0
Kiril Stanoev
Telerik team
answered on 26 Apr 2010, 03:19 PM
Hi Maria,

I've prepared a sample project trying to mimic your scenario. I did not find any problems using the LoadOnDemand and expanding features. Could you please have a look at it and let me know if I am missing something. I'd be glad to further assist you.

Best wishes,
Kiril Stanoev
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
Maria Im
Top achievements
Rank 1
answered on 26 Apr 2010, 05:36 PM
Thanks. That answered my question.
0
farhan iqbal
Top achievements
Rank 1
answered on 06 May 2010, 06:45 AM
I got a similar problem (with minor difference).
I don't have any specific format of data, i.e. I had to load any XML file in my treeview, so I've to do this on runtime. What I do is, I manually create RadTreeViewItem and add it in the treeview in Window_Loaded event. A sample tree view could be:
GrandFather
          Father1
          Father2
                Child1
                Child2
          Father3
                Child1

My problem is, if I had to expand a particular item (e.g., Father3 or GrandFather) RadTreeViewItem.IsExpanded = true not works for me, (either on window_Loaded or ItemPrepared)
0
farhan iqbal
Top achievements
Rank 1
answered on 06 May 2010, 07:13 AM
sorry for posting the already posted problem, this will solve the issue:
http://www.telerik.com/community/forums/wpf/treeview/item-selection-problem.aspx



Tags
TreeView
Asked by
Radu
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Radu
Top achievements
Rank 1
Maria Im
Top achievements
Rank 1
Kiril Stanoev
Telerik team
farhan iqbal
Top achievements
Rank 1
Share this question
or