This is a migrated thread and some comments may be shown as answers.
Drag and drop with Radtreeview nodes
5 Answers 111 Views
This is a migrated thread and some comments may be shown as answers.
Sandip
Top achievements
Rank 1
Sandip asked on 16 Mar 2011, 03:38 PM
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

5 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 17 Mar 2011, 10:43 AM
0
Jay
Top achievements
Rank 1
answered on 24 May 2012, 06:47 AM
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
0
Chetan
Top achievements
Rank 1
answered on 30 May 2013, 06:33 AM

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.

 

0
Nick
Telerik team
answered on 31 May 2013, 12:19 PM
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.

0
Chetan
Top achievements
Rank 1
answered on 02 Jun 2013, 07:10 AM
Thanks, for help.

That work for me as required.
Asked by
Sandip
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Jay
Top achievements
Rank 1
Chetan
Top achievements
Rank 1
Nick
Telerik team
Share this question
or