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

Drag and drop item into children

3 Answers 175 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andrei Rinea
Top achievements
Rank 1
Andrei Rinea asked on 24 Aug 2012, 01:05 PM

I am trying to implement drag-and-drop (holding CTRL pressed) of items into children. Although on DropQuery I set QueryResult to true the tree still denies dropping.

Any reason for this?

Any workaround?

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 29 Aug 2012, 09:05 AM
Hi Andrei,

Can you elaborate on how you're implementing your solution as at this point I cannot tell for sure what might be causing your issue? Also, you can have a look at our demos and specifically the RadTreeView Drag And Drop example as it demonstrates how to implement a drag/drop scenario between two RadTreeView controls. The showcased scenario allows you to move staff from the left tree only into the nodes of the right tree and if your requirements are similar, please take a closer look at the OnDropQuery() method implementation.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jean-Philippe
Top achievements
Rank 1
answered on 04 Sep 2012, 07:15 AM
Hallo Tina,

I am having a problem that seems similar to one of Andrei.
I have created an exaple project to demonstrate this.

What I try to achieve is to drag and drop an item to any other node. This means dropping a child to its direct parent or dropping a parent to its child.
In our program each node is an entry in virtual file system where this behavior is possible (and needed).

In the demo project there is one parent node, which contains two child nodes. You can simply drop on child on the other. But you cannot drop one of the child nodes to the parent node. This drop would result in copy (internally), creating a new node.

I found no event where I could enable this drop operation.

Download

Thank you

Jean-Philippe
0
Hristo
Telerik team
answered on 07 Sep 2012, 06:48 AM
Hello Andrei,

The TreeView internally handles part of the drag and drop operation. Dropping an item inside its parent is not allowed by the TreeView code base. That is why you should override the default TreeView behavior for dropping an item.

You should attach an event handler for the DropQuery event of the RadDragAndDropManager (for example RadDragAndDropManager.AddDropQueryHandler). This event is supposed to determine whether the dragged item could be dropped into the certain location or not. The boolean QueryResult property of the event args should be set to true when the drop operation is valid. In your case the TreeView sets this property to false disallowing the drop.

Please let us know if you face any issues or need further assistance on the topic.

All the best,
Hristo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Andrei Rinea
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Jean-Philippe
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or