This question is locked. New answers and comments are not allowed.
Srikrishna
Top achievements
Rank 1
Srikrishna
asked on 29 Jun 2012, 03:03 PM
Hi Telerik,
I am using RadTreeview and adding Items into Treeview dynamically from the database.How can i expand all the TreeviewItems on page load?
I tried on Item prepared event by using Treeview.Isexpanded = true; , but its not working. Treeview.IsExpanded is coming false when i viewed in debugging mode.
Thanks in Advance.
4 Answers, 1 is accepted
0
0
Srikrishna
Top achievements
Rank 1
answered on 03 Jul 2012, 01:54 PM
Hi Lancelot,
Thanks for the reply.
I used ExpandAll() method in the loaded event of the Treeview but it didn't work. I am loading treeview items dynamically from the database tables. Is this the problem?
private void TreeView_Role_Loaded(object sender, RoutedEventArgs e)
{
TreeView_Role.ExpandAll();
}
0
Accepted
Lancelot
Top achievements
Rank 1
answered on 03 Jul 2012, 02:06 PM
Your code looks perfect, so what you're probably experiencing is that the Treeview is not populated when you call for the ExpandAll method. You need to wait until you're sure the data is loaded, then call ExpandAll().
I dont know how your data is set up, but either check for all the data first or use a thread sleep method. If you know it takes a second for your data to populate the TreeView, the delay the method by a second.
Its not glamorous, but if your data needs the extra time to load then it will work. Just know that this is the order that you need to follow.
1 2 3 4
Page loads> TreeView Loads > Load Data > Expand All
#3 has to happen before you can use #4
Good Luck,
Lancelot
I dont know how your data is set up, but either check for all the data first or use a thread sleep method. If you know it takes a second for your data to populate the TreeView, the delay the method by a second.
Its not glamorous, but if your data needs the extra time to load then it will work. Just know that this is the order that you need to follow.
1 2 3 4
Page loads> TreeView Loads > Load Data > Expand All
#3 has to happen before you can use #4
Good Luck,
Lancelot
0
Srikrishna
Top achievements
Rank 1
answered on 04 Jul 2012, 01:08 PM
Thanks Lancelot. I got it resolved now.