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

Child restriction in treeview

3 Answers 51 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 12 Jul 2012, 12:47 PM
I was enabling a drag and drop in treeview but I want restrict nodes from having more than 2 children.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jul 2012, 01:17 PM
Hi Alan,

Try the following code to achieve your scenario.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true" onnodedrop="RadTreeView1_NodeDrop" >
 <Nodes>
 ..................
 </Nodes>
</telerik:RadTreeView>

C#:
protected void RadTreeView2_NodeDrop(object sender, Telerik.Web.UI.RadTreeNodeDragDropEventArgs e)
{
 RadTreeNode destNode = e.DestDragNode;
 if (destNode.Nodes.Count < 2)
 {
  destNode.Nodes.Add(sourceNode);
 }
}

Hope this helps.

Thanks,
Princy.
0
Ivana
Telerik team
answered on 16 Jul 2012, 03:45 PM
Hi Alan,

The following online demos shows a very good example of nodes' drag and drop functionality of RadTreeView on the client as well as on the server:
http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/draganddropnodes/defaultcs.aspx.

I hope it will help.

Kind regards,
Ivana
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.
0
Rakesh
Top achievements
Rank 1
answered on 04 Jun 2013, 06:15 AM
Hello Princy

It is possible to show cursor image as a validation on drag drop functionality ??
Tags
TreeView
Asked by
Alan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ivana
Telerik team
Rakesh
Top achievements
Rank 1
Share this question
or