Flex - Drag and drop - Drop a subset of multiple items
- by flanagann
I'm developing two DataGrid with drag and drop support. Multiple items can be selected from the source data grid, and dropped into the target data grid.
I'm using an drag and drop event listener which completes the operation only in certain cases. I'm using event.preventDefault() but it doesn't work, since it stops the drag and drop from all the items.
My aim is, for example, finally dropping 2 elements from the total 4 elements that I previously selected.
public function onDropPermission(event:DragEvent):void
{
var sourceGrid:mx.controls.DataGrid = new mx.controls.DataGrid();
sourceGrid = event.dragInitiator as mx.controls.DataGrid;
var targetGrid:mx.controls.DataGrid = new mx.controls.DataGrid();
targetGrid = event.target as mx.controls.DataGrid;
var i:int;
for (i = 0; i < sourceGrid.selectedIndices.length; i++)
{
var j:int;
for (j = 0; j < dataGroupPermissions.length; j++)
{
var permission:Permission = new Permission;
permission = dataGroupPermissions[j] as Permission;
if (permission.id == sourceGrid.selectedItems[i].id)
{
event.preventDefault();
}
}
}
}