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

Delayed load time of child nodes

9 Answers 173 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
BECK
Top achievements
Rank 1
BECK asked on 23 Oct 2010, 10:09 PM
Hey all, 

I have a very simple radtreeview structure. I basically have 3 root nodes and each node has 3 children. Every time I expand the tree node, there's a delay loading the child nodes. The delay isn't huge but it's a very noticeable delay compared to the original TreeView control. I suspect this has to do with the way the node appears (the turn on looking way). Is there a way to change that behavior so it's identical to the Windows TreeView control ?

Thanks

9 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 24 Oct 2010, 08:34 PM
Hello Beck,

You can do a couple of things to reduce the delay:
1. Set the ExpandAnimation property to None.
2. Set LoadOnDemand to false (this should be the default value).

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
BECK
Top achievements
Rank 1
answered on 27 Oct 2010, 05:01 PM
Thanks for the suggestions. They did help but I found out that the performance is significantly better if databinding is used as opposed to doing something like :
TreeView1.Nodes.Add(New .. )

I have another question about the RadTreeView (Winform); is there a way to style a node level for data bound RadTreeView control? In other words, because this is databound I would say something like any nodes in level 0 will have a forecolor of Blue. Is that possible?

THanks
0
Emanuel Varga
Top achievements
Rank 1
answered on 28 Oct 2010, 12:02 AM
Hello again Beck,

Yes, there is, and you can do it like so:
private void ChangeForeColorOfRootNodes()
{
    if (radTreeView1.Nodes.Count == 0)
    {
        return;
    }
 
    foreach (var rootNode in radTreeView1.Nodes)
    {
        rootNode.ForeColor = Color.Blue;
    }
}

If you are having problems using this method because the fact that the tree is not loaded before you call this method, you could try adding this line:
Application.DoEvents();
in the first line of the method.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
BECK
Top achievements
Rank 1
answered on 28 Oct 2010, 12:55 AM
Thank you for our reply. Applying styles to a nodes after the entire tree is populated is inefficient because I'm looping twice to do that. The first time is the loop to create the node (done by databinding in this case) and another to style the nodes. 

I was basically looking for an event like "OnRadTreeNodeAdding" event that's fired when a node is added via data binding. In that case, I would actually be able to style the node at the same time the node is created and added. 

0
Emanuel Varga
Top achievements
Rank 1
answered on 28 Oct 2010, 08:55 AM
Hello again Beck,

Sorry, but for the treeview there are no such events.
In my point of view it isn't that inefficient because whenever you are dealing with a tree structure you come to expect recursion in order to find a specific node, change something and so on.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Richard Slade
Top achievements
Rank 2
answered on 05 Nov 2010, 02:04 PM
Hi BECK, 

There may be another way to do this. If I have it right what you want to do, you could try subscribing to the collection changed and collection changing events as described in this forum post

Let me know if that helps
Richard
0
Stefan
Telerik team
answered on 11 Nov 2010, 01:12 PM
Hi guys

Thank you all for writing.

The suggestions that Richard and Emanuel provided are correct and you can use either one of them. The difference is that when this is done in the CollectionChanged event all newly added nodes will be styled, and if you use the for loop suggestion, you will not have this functionality.

Let us know which way is more convenient for you if you find a difference in the loading time. Additionally, if you need further assistance, please share with us what is the size of the data that you are loading in RadTreeVIew or even better provide me with a sample project in a new support ticket.

 
Best wishes,
Stefan
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
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 04 Jan 2011, 08:05 PM
Make sure you wrap your creation of child nodes code with BeginUpdate() / EndUpdate(). This speeds things up quite a bit.
0
Kavita
Top achievements
Rank 1
answered on 02 Jan 2012, 10:11 AM
Hi,
 
I am using latest version of telerik.I want to put some delay while expanding the tree node.Can anyone please help me in this.
Tags
Treeview
Asked by
BECK
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
BECK
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Stefan
Telerik team
erwin
Top achievements
Rank 1
Veteran
Iron
Kavita
Top achievements
Rank 1
Share this question
or