Treeview with multiple listview to drag and drop

Hi, I have a single treeview and two or more listview where I can drag and drop from the treeview. How do I separate on which listview an item is dropped from the treeview? Is it possible to do this with the treeview component?


5 Replies

SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team February 22, 2022 11:16 AM UTC

Hi Simon, 
 
Greetings from Syncfusion support. 
 
Please, refer the following demo link in which we have used two TreeView and a ListView for performing drag and drop among them. 
 
 
 
Query: How do I separate on which listview an item is dropped from the treeview? 
 
We suspect your requirement is to prevent dropping tree node into any particular ListView. You can achieve this validating the dropped element id in OnNodeDragStop before node is added with ListView. 
 
Refer the following links to know the arguments of OnNodeDragStop event of TreeView. 
 
 
 
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 
 
 



SL Stefan Limpert March 16, 2023 12:40 PM UTC

Hi Shameer,
i'm dealing with the same request. I copy and paste the drag & drop demo sample in my project, just to analyse the prperties in action.
Here are my results:
JS-Interop throws an error, because "OnDragStopCall" was not found.

await JSRuntime.InvokeAsync<NodeData>("OnDragStopCall", args);

so if i deactivate the JS-Interop call, the DragAndDropEventArgs.Target is always null, so i cannot determine the object to node was dropped in.

my current SF version is 20.3.0.47 on Blazor Server .NET6.

Why did the JSInterop getting error?
Were the properties DropTarget an Target setted by this JS method?

What did i miss?

Regards

Stefan



IL Indhumathy Loganathan Syncfusion Team March 17, 2023 07:55 AM UTC

Hi Stefan,


In our demo sample, we have achieved drag and drop between multiple nodes by making an interop call. Check out the below code snippet.


function OnDragStopCall(dragEventArgs) {

    var targetElement = document.elementFromPoint(dragEventArgs.left, dragEventArgs.top);

    var listEle = targetElement.closest(".e-droppable");

    if (listEle && listEle.classList.contains("custom-list")) {

        var id = dragEventArgs.draggedNodeData.id;

        var text = dragEventArgs.draggedNodeData.text;

        return { Id: id, Text: text };

    }

}


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorTreeView-1948285921


The above customization enabled to perform Drag and Drop from TreeView to ListView component. We will add this to our demo section and refresh it in any of our upcoming releases. Check out the shared sample and get back to us if you need any further assistance.


Regards,

Indhumathy L



SL Stefan Limpert March 18, 2023 10:17 AM UTC

Hi Indhumathy,
it was'nt not  the complete answer, but it leads me to it.
So, thank you for your suggestions.

Regards

Stefan



IL Indhumathy Loganathan Syncfusion Team March 20, 2023 06:43 AM UTC

Stefan, We are happy to hear that the provided suggestions were helpful. Please get back to us if you need any further assistance.


Loader.
Up arrow icon