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

Expand all root items

6 Answers 178 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 23 Jul 2010, 08:42 AM
Hi, I need to make sure that all root nodes are expanded on initial load. With the CTP version of RadTreeListView (based on RadTreeView), I used the following:

void HierarchyTree_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
{
    RadTreeViewItem item = e.PreparedItem;
 
    //Root items should be expanded on initial load
    if (item.IsRootItem)
        item.IsExpanded = true;
}


What is the simplest equivalent in the current version of RadTreeListView?

/Henrik

6 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 23 Jul 2010, 05:15 PM
Hi hwsoderlund,

 You can handle the DataLoaded event of RadTreeListView like so:

void treeListView_DataLoaded(object sender, EventArgs e)
{
    var source = this.treeListView.ItemsSource as ICollection;
    if (this.treeListView.Items.Count == source.Count)
    {
        foreach (var item in source)
        {
            this.treeListView.ExpandHierarchyItem(item);
        }
    }
    else if (this.treeListView.Items.Count > source.Count)
    {
        this.treeListView.DataLoaded -= this.treeListView_DataLoaded;
    }
}

All the best,
Yavor Georgiev
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
Francois Lamy
Top achievements
Rank 1
answered on 05 Aug 2010, 02:29 PM
When I try to call ExpandHeirarchyItem in response to the DataLoaded event, I get an error 'Value does not fall in expected range', seemingly because there are no items in the treeListView.Items collection yet.  Am I missing something?
0
Yavor Georgiev
Telerik team
answered on 09 Aug 2010, 08:44 AM
Hi Thomas Whittaker,

 Could you please post some code snippets so that I can learn a bit more about your scenario? A sample project would be best, though. If you are willing to send us a sample application, please open a support ticket. Either way, I'll try to help you as quickly as possible.

Sincerely yours,
Yavor Georgiev
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
Francois Lamy
Top achievements
Rank 1
answered on 10 Aug 2010, 01:03 PM
I am not exactly sure what I was doing wrong.  When I went back later and put my ExpandHierarchyItem call in the RowLoaded event handler, it worked.  I haven't gone back to try the DataLoaded event handler because RowLoaded was what I wanted anyway.
0
Ivano
Top achievements
Rank 1
answered on 03 Jun 2011, 08:45 AM
Hi

your example works fine but when I set RadTreeListView.ItemsSource again DataLoaded event is no more fired; how shuold I expand all roots any time I set ItemsSource?

Thanks
0
Richard M
Top achievements
Rank 1
answered on 27 Sep 2011, 11:00 PM
Reattach the event before you set the item source
Tags
TreeListView
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Francois Lamy
Top achievements
Rank 1
Ivano
Top achievements
Rank 1
Richard M
Top achievements
Rank 1
Share this question
or