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:
What is the simplest equivalent in the current version of RadTreeListView?
/Henrik
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
0
Hi hwsoderlund,
All the best,
Yavor Georgiev
the Telerik team
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;
}
}
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
Hi Thomas Whittaker,
Yavor Georgiev
the Telerik team
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
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