LoadOnDemand

7 posts, 0 answers
  1. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 08 Sep 2007 Link to this post

    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
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 10 Sep 2007 Link to this post

    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
  3. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Sep 2007 Link to this post

    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);

    }

    }


  4. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 10 Sep 2007 Link to this post

    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
  5. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Sep 2007 Link to this post

    thanks,

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

    thanks for reply
    almir
  6. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Sep 2007 Link to this post

    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
  7. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 11 Sep 2007 Link to this post

    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
Back to Top