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

Drag and drop in treeview

1 Answer 62 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 04 Jul 2012, 09:18 AM
Hi,

I need to implement drag and drop on a treeview in such a way that it should allow drag and drop only between same level of nodes.

Thanks,
Stephen Lewis

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 04 Jul 2012, 10:08 AM
Hi Stephen,

Here is the sample code which I tried based on your scenario.

C#:
protected void RadTreeView1_NodeDrop(object sender, Telerik.Web.UI.RadTreeNodeDragDropEventArgs e)
  {
    RadTreeNode sourceNode = e.SourceDragNode;
    RadTreeNode destNode = e.DestDragNode;
    RadTreeViewDropPosition dropPosition = e.DropPosition;
    if (sourceNode.Level == destNode.Level+1)
    {
      destNode.Nodes.Add(sourceNode);
    }
  }

Hope this helps.

Thanks,
Princy.
Tags
TreeView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or