Hello
I am creating a number of RadTreeView controls at run time:
I am struggling to see how to assign the OnNodeExpand event to a code behind event.
With a static declaration this was :
But I can't see a property at runtime that matches OnNodeExpand.
Please could anyone help me with the answer.
Thankyou
I am creating a number of RadTreeView controls at run time:
RadTreeView MyTree = new RadTreeView();I am struggling to see how to assign the OnNodeExpand event to a code behind event.
With a static declaration this was :
<telerik:RadTreeView OnNodeExpand="RadPopulateNode">But I can't see a property at runtime that matches OnNodeExpand.
Please could anyone help me with the answer.
Thankyou
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 10 Jan 2012, 03:07 PM
Hello,
Try the following code.
C#:
Thanks,
Princy.
Try the following code.
C#:
protected void Page_Load(object sender, EventArgs e) { RadTreeView RadTreeView1 = new RadTreeView(); RadTreeView1.NodeExpand += new RadTreeViewEventHandler(RadTreeView1_NodeExpand); }void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e) { //your code }Thanks,
Princy.
0
richard
Top achievements
Rank 1
answered on 10 Jan 2012, 03:51 PM
FAB
Thanks Princy
Thanks Princy
0
richard
Top achievements
Rank 1
answered on 10 Jan 2012, 05:22 PM
Hi Princy
having trouble as the event won't fire:-
see thread :
http://www.telerik.com/community/forums/aspnet-ajax/splitter/reference-controls-from-javascript.aspx
Thought you might be able to see what could be wrong.
Thanks
Richard
having trouble as the event won't fire:-
see thread :
http://www.telerik.com/community/forums/aspnet-ajax/splitter/reference-controls-from-javascript.aspx
Thought you might be able to see what could be wrong.
Thanks
Richard
0
richard
Top achievements
Rank 1
answered on 10 Jan 2012, 07:21 PM
I tried moving the code to Page_PreRender from Page_Load but then receive this error when trying to expand the node:
"The target 'ctl03' for the callback could not be found or did not implement ICallbackEventHandler"
Code now reads:
// Dynamically create sliding panes and tree view in each pane foreach (XmlNode xn in xnList) { // Create a new Tab RadSlidingPane leftSlidingPane = new RadSlidingPane(); leftSlidingPane.Title = xn["label"].InnerText; leftSlidingPane.Overlay = true; leftSlidingPane.MinWidth = 50; leftSlidingPane.Width = 300; // Add the sliding panel to the left sliding zone ExploreSlidingZone.Items.Add(leftSlidingPane); // Create tree view RadTreeView myTree = new RadTreeView(); myTree .NodeExpand += new RadTreeViewEventHandler(RadPopulateNode); myTree .OnClientNodeClicking = "ClientNodeClicking"; myTree .ShowLineImages = true; myTree .OnClientContextMenuShowing = "OnClientContextMenuShowing"; // Create root node RadTreeNode ExploreRootNode = new RadTreeNode(" " + xn["label"].InnerText); // Set root node properties ExploreRootNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; ExploreRootNode.PostBack = false; // add the root node to the sliding pane myTree .Nodes.Add(ExploreRootNode); // Bind context menu to treeview BindContextMenu(myTree ); // Add treeview to sliding pane leftSlidingPane.Controls.Add(myTree ); } ---------------------- protected void RadPopulateNode(object sender, RadTreeNodeEventArgs e) { RadBindTreeToDirectory(e.Node); }0
Hi Richard,
Hope this will be helpful. If you have further questions please don't hesitate to ask.
All the best,
Plamen Zdravkov
the Telerik team
Thank you for contacting Telerik support.
Here is a code that adds the tree dynamically:
Copy Code
protected void Page_Load(object sender, EventArgs e) { RadTreeView view = new RadTreeView(); view.ID = "test"; view.NodeExpand += new RadTreeViewEventHandler(view_NodeExpand); RadTreeNode node1 = new RadTreeNode("a"); view.Nodes.Add(node1); node1.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; this.form1.Controls.Add(view); } void view_NodeExpand(object sender, RadTreeNodeEventArgs e) { e.Node.Nodes.Add(new RadTreeNode(e.Node.Text + "1")); e.Node.Nodes.Add(new RadTreeNode(e.Node.Text + "2")); e.Node.Nodes.Add(new RadTreeNode(e.Node.Text + "3")); }Hope this will be helpful. If you have further questions please don't hesitate to ask.
All the best,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
