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

move nodes between treeviews, but not between nodes of the same treeview

5 Answers 54 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Zeus_developer
Top achievements
Rank 1
Zeus_developer asked on 18 May 2012, 09:22 PM
Hi,

I'm trying the ASP.NET AJAX suite, and I don't know how to solve this function:

I have two treeviews: 
  1. First treeview will receive nodes from second treeview
  2. node from one treeview can't be moved to nodes of the same treeview
  3. nodes of second treeview can be moved only to first treeview
  4. nodes of first treeview can't be moved to second treeview 

I try to implement the functionality: processes(first preeview) and activities(second treeview), where a process can have multiple activities, but a activity can't have processes as child.

I hope you can help me.

Regards

5 Answers, 1 is accepted

Sort by
0
Zeus_developer
Top achievements
Rank 1
answered on 19 May 2012, 04:23 PM
no idea?
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 May 2012, 07:46 AM
Hi,

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

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="false">
.............
</telerik:RadTreeView>
<telerik:RadTreeView ID="RadTreeView2" runat="server" EnableDragAndDrop="true"  EnableDragAndDropBetweenNodes="false" onnodedrop="RadTreeView2_NodeDrop" >
..............
</telerik:RadTreeView>

C#:
protected void RadTreeView2_NodeDrop(object sender, Telerik.Web.UI.RadTreeNodeDragDropEventArgs e)
    {
        RadTreeNode sourceNode = e.SourceDragNode;
        RadTreeNode destNode = e.DestDragNode;
        RadTreeViewDropPosition dropPosition = e.DropPosition;
        if ((sourceNode.TreeView.Equals(destNode.TreeView)) || ((sourceNode.TreeView == RadTreeView2) && (destNode.TreeView != RadTreeView1)))
        {
            return;
        }
        else
        {
            destNode.Nodes.Add(sourceNode);
        }
    }

Hope this helps.

Thanks,
Princy.
0
Zeus_developer
Top achievements
Rank 1
answered on 21 May 2012, 09:18 PM
Princy,

Thanks for your response, it solves part of the problem.

I'm attaching two images where I describe two cases to validate

please take a look at the images and help me to get a solution.

Best regards.
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 May 2012, 05:28 AM
Hi,

Based on your scenario I have modified the code as follows.

C#:
protected void RadTreeView2_NodeDrop(object sender, Telerik.Web.UI.RadTreeNodeDragDropEventArgs e)
    {
        RadTreeNode sourceNode = e.SourceDragNode;
        RadTreeNode destNode = e.DestDragNode;
        RadTreeViewDropPosition dropPosition = e.DropPosition;
        if ((sourceNode.TreeView.Equals(destNode.TreeView)) || ((sourceNode.TreeView == RadTreeView2) && (destNode.TreeView != RadTreeView1)) || (destNode.Level != 0))
        {
            return;
        }
        else
        {
            destNode.Nodes.Add(sourceNode);
        }
    }

Hope this helps.

Thanks,
Princy.
0
Zeus_developer
Top achievements
Rank 1
answered on 22 May 2012, 03:49 PM
Thanks Princy,

that's the solution,  you did it again!!

Best regards.
Tags
TreeView
Asked by
Zeus_developer
Top achievements
Rank 1
Answers by
Zeus_developer
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or