Problem with NodeExpand

4 posts, 0 answers
  1. Himadri Banerjee
    Himadri Banerjee avatar
    14 posts
    Member since:
    Dec 2005

    Posted 28 Nov 2008 Link to this post

    I have created a simple TreeView and have some nodes created from the code behind. I have tried to set the RootNode's NodeExpand ClientSide, ServerSide, ServerSideCallBack. I just can't seem to expand a node through my code behind. I have tried to use OnClientNodePopulated and tried to expand. Nothing works. My first node always opens collapsed. I can't even find a Expand() method on a node. I do have ExpandChildNodes(), and that is what I am calling but no luck so far.  I really need help on this. This is what I have
             RadTreeView1.Nodes.Clear();
                RadTreeNode node = new RadTreeNode();
                node.Category = "Root";
                node.Value = Guid.Empty.ToString();
                node.Text = "Functional Positions";
                node.Checkable = false;
    //added the following line just so I have a child node
                node.Nodes.Add(new RadTreeNode("dummy");
               
                node.ExpandMode = TreeNodeExpandMode.ServerSide;    // I have tried setting ClientSide, ServerSide
                RadTreeView1.Nodes.Add(node);
                RadTreeView1.Nodes[0].ExpandChildNodes();

    what I want at this point the TreeView to fire it's NodeExpand Method so I can load the actual nodes from the database.
    Can you please help?

    Thanks
    himadri
  2. Yana
    Admin
    Yana avatar
    4815 posts

    Posted 01 Dec 2008 Link to this post

    Hi Himadri,

    node.ExpandChildNodes() means that the childs of "node" should be expanded, in your case it's the node with text "dummy", but it has no childs, so there's no result. You can expand a node like this:

    RadTreeView1.Nodes[0].Expanded = true

    but this will not fire OnNodeExpand event, because it's fired only by user interaction (mouse click) or by calling the expand() client-side method. 

    Best wishes,
    Yana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Himadri Banerjee
    Himadri Banerjee avatar
    14 posts
    Member since:
    Dec 2005

    Posted 03 Dec 2008 Link to this post

    So really what you are saying that there is no way fire a node expand method from the code behind. I personally think that is something developers will need based on various logic. Without that it is hard for users to see for example what values they have previously selected/checked etc. unless I load the whole treeview with lots of nodes. Are you going to change that behaviour at some point.

    Thanks
    Himadri
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 04 Dec 2008 Link to this post

    Hello Himadri Banerjee,

    We do not have plans to change that behavior.

    The reason is simple - instead of firing the NodeExpand event in order for you to execute some code, you can place that code after setting the Expanded property to True.

    You might find this article helpful: Troubleshooting > Expanding nodes

    I hope this helps.

    Sincerely yours,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top