This is a migrated thread and some comments may be shown as answers.

dragging multiple rows from a listview to another listview

1 Answer 149 Views
Drag and Drop
This is a migrated thread and some comments may be shown as answers.
BRAD
Top achievements
Rank 1
BRAD asked on 09 Dec 2014, 06:41 AM
Hi there.  I'm having trouble dragging multiple rows from a listview into another listview.  Please see this plunker: http://plnkr.co/edit/FdMjVVLVHRcpHTCjhsT6?p=info for a description of what i'm working on.  the listview on the bottom has little circle 'X''s that i should be able to drag into the top listview.  I have 'multiple' select set for the bottom listview, so i would like to ctrl-click on the rows in the bottom list view to drag multiple, but  e.draggable.currentTarget is always just an array of 1, it never shows the other rows.  How do I fix this?  If i have to reachback and look at the listviews currently selected rows, instead of just looking at what is dropped, i'm fine with that, but that doesn't seem to work either.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 11 Dec 2014, 09:10 AM
Hello Brad,

This is expected as every item is a draggable and only one item can be dragged at a time. You can however expand the logic inside `droptargetOnDrop` method a bit in order to get all selected items from the ListView and drop them.

Here is how the code might be implemented:
$scope.droptargetOnDrop = function(e) {
    $(".dragging").removeClass("dragging");
    //var dragid = e.draggable.currentTarget[0].id;
    var widget = e.draggable.currentTarget.closest("[data-role=listview]").data("kendoListView");
    var selectedItems = widget.select();
    var dragid = "";
    
    if (selectedItems.length) {
      dragid = selectedItems.map(function() { 
        return widget.dataItem(this).EmployeeID; 
      }).toArray().join(" ,"); 
    } else {
      dragid = e.draggable.currentTarget[0].id;
    }

    $scope.droptargetOnDragLeave(e);
    var dropid = e.dropTarget[0].id;
    alert("dragid=" + dragid + ", dropid=" + dropid)
  };

Updated example: http://plnkr.co/edit/PiXAy41YDsI3wPCYy7LM?p=preview.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Drag and Drop
Asked by
BRAD
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or