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

LoadOnDemand

6 Answers 163 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
almir
Top achievements
Rank 1
almir asked on 08 Sep 2007, 11:04 PM
Hi,

is thera a way to implement load-on-demeand or should i always load all the nodes ?

I would like to be able to set node's property on -LoadOnDemand and add some event-handlers to my treeview and can load nodes as they are needed by client and not to load them in advance

thanks
almir

6 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 10 Sep 2007, 11:42 AM
Hi almir,

Yes, RadTreeView supports load on demand. The intended way of implementing load on demand is to use the NodeExpandedChanged or NodeExpandedChanging events of RadTreeView to load nodes in combination with the LoadedOnDemand property of RadTreeNode to determine the visibility of an expand/collapse button.

Do not hesitate to ask if you have any other questions about RadTreeView.
 

Best wishes,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
almir
Top achievements
Rank 1
answered on 10 Sep 2007, 12:40 PM
Hi,

the problem with standard load on demand that each node in this case has + sign on it side, which makes user very angry - they have to click to find out if there is child nodes, and i could perform this step in my code and tell the user that this node does not have any children. What would be great is to have property for each node like CanExpand, IsExpandble , ShowExpandIcon or something like, this property shoul be setted appropriatly, and than in NodExpanding event user could add nodes.

my current workaround is, that ia am checking if node should have + sign, if true I add a dummy node, this will create plus, and than in my Expanding event i check if the first node is my dummy node and remove it and append real nodes afterward. below are methods 


private void BindElementToTree( RadTreeNode node, treeBindable element){

RadTreeNode childNode = new RadTreeNode();

childNode.Text = element.Text;

childNode.ContextMenu = radDropDownMenu1;

if (element.HasChildren)

{

childNode.Nodes.Add("dummy");

}

childNode.LoadedOnDemand = true;

childNode.Tag = element;

 

node.Nodes.Add(childNode);

 

}

void radTreeView1_Expanding(object sender, System.ComponentModel.CancelEventArgs e)

{

RadTreeNode parent = (RadTreeNode)sender;

//check if it only has a single node and it is our dummy node withoout tag inside, if there are more than one node , this node has already all of its kids and there is no need to do anything

if(parent.Nodes.Count>0 && parent.Nodes[0].Tag==null)

{

//remove dummy node

parent.Nodes[0].Remove();

Role role = (Role)parent.Tag;

BindElementsToTree(parent, role.Children);

}

}


0
Jordan
Telerik team
answered on 10 Sep 2007, 04:50 PM
Hello almir,

If a node's LoadedOnDemand property has a value of false, and the LoadOnDemand property of the treeview is true
then the expand/collapse button for that node is shown regardless of the child node count. In other words to achieve the effect you are after you need to do the following:
  1. set the  LoadOnDemand property of your treeview to true
  2. set the LoadedOnDemand property to false for the nodes that must have an expand/collapse button, and to true for those that must not have one.
Hope that helps.

Kind regards,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
almir
Top achievements
Rank 1
answered on 10 Sep 2007, 05:00 PM
thanks,

i will try it out in few hours, my view was completly oposit,

thanks for reply
almir
0
almir
Top achievements
Rank 1
answered on 10 Sep 2007, 06:45 PM
Great It worked,

however I could not find the events you were mentioning NodeExpandedChanged or NodeExpandedChanging  so I used NodeExpand, is it new API you have or is it only typo?

thanks once more for great support
almir
0
Boyko Markov
Telerik team
answered on 11 Sep 2007, 02:43 PM
Hi almir,

From your last post we understand that you are using Q1 SP2. For some reason we thought that you are using the beta version, which offers these properties. In the beta we have made some changes in the API of RadTreeView especially in its events. 

Last week we released the beta version of the WinForms suite which you can download from here: http://www.telerik.com/community/forums/thread/b311D-htmdd.aspx. Please, download it and try NodeExpandedChanged and NodeExpandedChanging out.

We have walked a long way over the last couple of months to improve the quality and performance of our controls. We also had some time for the development of a brand new component - RadCalendar. Feel free to share your feedback on it as well.

If you have any further questions about RadTreeView or our controls at all, please feel free to write us.

 
Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Treeview
Asked by
almir
Top achievements
Rank 1
Answers by
Jordan
Telerik team
almir
Top achievements
Rank 1
Boyko Markov
Telerik team
Share this question
or