Drag and drop with Radtreeview nodes

6 posts, 0 answers
  1. Sandip
    Sandip avatar
    15 posts
    Member since:
    Nov 2010

    Posted 16 Mar 2011 Link to this post

    Hi;
        Am having RadGridView and RadTreeView. Am dragging & dropping items from the GridView to different the nodes of a Treeview. This is working fine. We have used "IsDragDropEnabled="True" in RadTreeView for performing task. In the same time am able to rearrange the nodes(performing drag & drop within different nodes of same RadTreeView). This i would like to stop. Please have a look on the attached image for your reference.

    Thanx in advance.

    --Sandy
  2. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts
  3. DevCraft banner
  4. Jay
    Jay avatar
    5 posts
    Member since:
    Mar 2012

    Posted 24 May 2012 Link to this post

    Hi,

    We had a requirement as follows:
    An item can be moved around among its sibilings below the same parent only.

    if (e.TargetDropItem != null  && draggedItems != null && draggedItems.Count > 0 )
                {
                    Node targetNode = (Node)(e.TargetDropItem.Header);
                    if (e.TargetDropItem.ParentItem != null && targetNode != draggedItems[0] as Node)
                    {
                        if (e.DropPosition == DropPosition.After || e.DropPosition == DropPosition.Before)
                        {                       
                            if (targetNode.ParentNode != (draggedItems[0] as Node).ParentNode)
                            {
                                e.TargetDropItem.ParentItem.IsDropAllowed = false;
                            }
                            else
                            {
                                e.TargetDropItem.ParentItem.IsDropAllowed = true;
                            }
                        }
                        else if (e.DropPosition == DropPosition.Inside)
                        {
                            if (e.TargetDropItem == draggedItems[0] ||
                                targetNode != (draggedItems[0] as Node).ParentNode)
                            {
                                e.TargetDropItem.IsDropAllowed = false;                          
                            }
                            else
                            {
                                e.TargetDropItem.IsDropAllowed = true;
                            }
                        }
                        else
                        {
                            e.TargetDropItem.IsDropAllowed = false;
                        }
                    }
                    else
                    {
                        e.TargetDropItem.IsDropAllowed = false;
                    }
                }

    The problem is that when we drag the last treeview item downwards, the e.dropitem is self but the visual indication is displayed below the root treeview item. On mouseup, the item is dropped as a sibiling to the root treeview item.

    Please advice

    Thanks
    Jay
  5. Chetan
    Chetan avatar
    26 posts
    Member since:
    Oct 2012

    Posted 30 May 2013 Link to this post

    Hi,

    i want dragdropEnable = true for tree view. But dropping in other control not in tree view.

    I have tried with
    <telerik:RadTreeViewItem Header="Tennis" IsDropAllowed="False">

    and work with node added at design time in Xaml.

    but how could this achieve with tree source given with hirachical data source.

    Then I have tried with

    DragDrop.

     
    DragDropManager.AddDropHandler(tvDeviceExplorerModel, AddressOf OnDropE, True)
    'tvDeviceExplorerModel >> tree control name

        
      
    Private Sub OnDropE(sender As Object, args As Telerik.Windows.DragDrop.DragEventArgs) 
         DirectCast(sender, Telerik.Windows.Controls.RadTreeView).AllowDrop = False 
    End Sub

    here instead of AllowDrop = False I want some event by which I can cancel the drop tree node within tree node.
    Please help me on same.

    Thanks in advance.

     

  6. Nick
    Admin
    Nick avatar
    593 posts

    Posted 31 May 2013 Link to this post

    Hello Chetan,

    You can handle the DragOver event and set the Effects to None if you don't want the drop to be enabled.

    Hope this helps! 

    Regards,
    Nik
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Chetan
    Chetan avatar
    26 posts
    Member since:
    Oct 2012

    Posted 02 Jun 2013 Link to this post

    Thanks, for help.

    That work for me as required.
Back to Top
DevCraft banner