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?
3 Answers, 1 is accepted
answered on 29 Aug 2012, 09:05 AM
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.
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.
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.