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

Problem with NodeExpand

3 Answers 91 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Himadri Banerjee
Top achievements
Rank 1
Himadri Banerjee asked on 28 Nov 2008, 03:18 PM
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

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 01 Dec 2008, 02:50 PM
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.
0
Himadri Banerjee
Top achievements
Rank 1
answered on 03 Dec 2008, 10:33 AM
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
0
Veselin Vasilev
Telerik team
answered on 04 Dec 2008, 12:54 PM
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.
Tags
TreeView
Asked by
Himadri Banerjee
Top achievements
Rank 1
Answers by
Yana
Telerik team
Himadri Banerjee
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or