TreeView drag and drop multiple items

2 Answers 309 Views
TreeView
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Aleksandr asked on 05 Jul 2021, 08:12 PM
seems even having multiple selection we just can drag and drop items one by one, am I right? basically having access to selected items & grop event i can code workaround & move them myself, but hope that we have it out of the box, do we?  
Marin Bratanov
Telerik team
commented on 06 Jul 2021, 05:58 PM

The item selection and item dragging are generally slightly separate features, one does not really require the other. I am not sure I completely understand the issue, though, so I would encourage you to edit the opener post to provide some more details on the problematic scenario.
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
commented on 06 Jul 2021, 07:37 PM

set treeview selection type to multiple, select several items, try to drag, just one item will be dragged despite having several selected

2 Answers, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 09 Jul 2021, 10:47 AM

Hello Aleksandr,

Thanks to your question, we have opened a feature request for the described functionality in our public feedback portal:

https://feedback.telerik.com/blazor/1527198-treeview-drag-and-drop-multiple-items-with-multiple-selection

We prioritize feature requests, based on interest and demand. That is why I voted on your behalf to increase the item's priority. You will also get notified via email about its status changes.

The drag and drop feature of the TreeView drags only the currently dragged node. Selection is a separate feature. This is why the workaround you mentioned is the only possible approach at the moment that can allow you to drag and drop multiple items.

Let me know if you need any additional information.

Regards,
Hristian Stefanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andrew
Top achievements
Rank 1
Iron
Iron
answered on 28 Jun 2022, 09:07 PM

Aleksandr,

I have the same requirement and was able to support it with minimal effort.

In the drop event use this technique. If the tree selection contains the dragged item then the user dragged the entire selection and you can use TreeSelection (property bound to SelectedItems) as the list of what was dragged. If on the otherhand TreeSelection does NOT contain the drag item, then the user made a selection but dragged a different node. In this scenario the dragged node (from arg.Item) is the only item that was dragged.

            var selectedItems = TreeSelection.OfType<TreeViewModel>().ToList();
            var draggedItem = arg.Item as TreeViewModel;
            if (!selectedItems.Contains(draggedItem))
                selectedItems = new List<TreeViewModel>() { draggedItem };

Good luck,

-Andy

Tags
TreeView
Asked by
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Answers by
Hristian Stefanov
Telerik team
Andrew
Top achievements
Rank 1
Iron
Iron
Share this question
or