Is there a way to do drag and drop with multiple items in a Grid? I have multiselect enabled and drag and drop enabled, but it only drops the row I clicked on to do the drag. It seems like the data object made available by the beforeRowDrop and afterRowDrop should support multiple rows since the source property is an array, but it only ever seems to have the ID of the row I clicked on to start the drag. Is there something I’m missing in the documentation that tells how to enable dragging multiple rows?
Unfortunately, currently, it is not available to drag multiply selected rows at once. We know about that limitation and we’re planning to eliminate it in the future updates.
Thank you for the response. I have another thread in this forum about the “beforeRowDrop” event not working for the Grid; if that was working, I could use that event to read the Selection object for the grid and manually manipulate (copy or move) the rows, then return false to prevent the default drop action from happening. So I think there is a workaround for this limitation, but it’s prevented by what I’m certain is just a small bug.
My apologies for missing that post.
The thing is that the beforeRowDrop
occurs for the target grid, not for the source.
For my code it doesn’t matter which grid fires the event. I just need it to fire to cancel the standard drop action and call my own copy function instead. But as I noted in the other thread, the event is not firing at all.
I figured out a way to do it using the afterRowDrop with a little extra code:
gridTarget.events.on("afterRowDrop",function(data,e){
var sel = gridSource.data.selection.getCells();
for (var i=0;i<sel.length;i++){
if (sel[i].row.id !== data.start){
var item = gridSource.data.getItem(sel[i].row.id);
// I have some code here to modify the item before putting it into the target grid
gridTarget.data.add(item);
// next line is only if doing a move instead of a copy
gridSource.data.remove(sel[i].row.id);
}
}
}
Using the beforeRowDrop event and returning false would remove the
sel[i].row.id !== data.start
check.
We’ve extended the possibility to use the drag’n’drop with the multiselection in the dhx.Grid latest update (v8.0)
You can test it here:
Please, download the latest available dhx.Suite build from your client’s area to get this functionality.