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

6 posts, 2 answers
  1. Zeus_developer
    Zeus_developer avatar
    14 posts
    Member since:
    Jun 2006

    Posted 18 May 2012 Link to this post

    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
  2. Zeus_developer
    Zeus_developer avatar
    14 posts
    Member since:
    Jun 2006

    Posted 19 May 2012 Link to this post

    no idea?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 May 2012 Link to this post

    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.
  5. Zeus_developer
    Zeus_developer avatar
    14 posts
    Member since:
    Jun 2006

    Posted 21 May 2012 Link to this post

    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.
  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 May 2012 Link to this post

    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.
  7. Zeus_developer
    Zeus_developer avatar
    14 posts
    Member since:
    Jun 2006

    Posted 22 May 2012 Link to this post

    Thanks Princy,

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

    Best regards.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017