We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Mulitple drag & drop issue

Hello,

Below is my code for tree view.

  @(Html.EJ().TreeView("tree").AllowDragAndDrop(true).AllowMultiSelection(true)
            .TreeViewFields(field =>
                field.Datasource((List<TM>)ViewBag.Tasks)
                .Id("ID")
                .ParentId("ParentID")
                .Text("TaskName")
            ).Template("#treeTemplate").ClientSideEvents(e=>e.NodeDragStop("NodeDropped"))
    )


<script>
    function NodeDropped(args) {
        debugger
        console.log(args.draggedElementData)
        console.log(args.targetElementData)
       

    }
</script>

The problem is,in case of multiple elements get dragged i'm getting only the first dragged element. If i drag 3 elements together,how to access all of them while drag and drop? I don't mind if the different event should be used.

1 Reply

PR Piramanayagam Ramakrishnan Syncfusion Team May 24, 2017 11:59 AM UTC

Hi Kuntal, 
 
Thanks for contacting Syncfusion support. 
 
We didn’t provide the all dragged node details in event arguments due to performance leak. But we can get all dragged nodes by using public method “getSelectedNodes” while drag and drop. This method returns all selected nodes element. Please refer to below code sample, 
 
[script] 
function NodeDropped(args) { 
    //check multiple nodes are dragged or not 
    if (this.model.allowMultiSelection && args.draggedElement.find("> div > a").hasClass("e-active") && this.model.selectedNodes.length > 1) { 
        //get all draggedNodes element 
        var selNodes = this.getSelectedNodes(); 
        for (var i = 0; i < selNodes.length; i++) { 
            //get each dragged node element 
            console.log($(selNodes[i])); 
        } 
    } 
    else { 
        console.log(args.draggedElement); 
    } 
} 
 
For your reference, we have prepared a simple sample based on this, and it can be downloaded from the following location: Sample 
 
Please let us know whether the provided sample was helpful in achieving your requirement. If not, send us more information to proceed further.   
 
Regards, 
Piramanayagam R

Loader.
Live Chat Icon For mobile
Up arrow icon