Drag and drop item into children

4 posts, 0 answers
  1. Andrei Rinea
    Andrei Rinea avatar
    10 posts
    Member since:
    Jun 2008

    Posted 24 Aug 2012 Link to this post

    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?

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 29 Aug 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Jean-Philippe
    Jean-Philippe avatar
    3 posts
    Member since:
    May 2012

    Posted 04 Sep 2012 Link to this post

    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
  5. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 07 Sep 2012 Link to this post

    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.

Back to Top