Flex - Drag and drop - Drop a subset of multiple items
Posted
by flanagann
on Stack Overflow
See other posts from Stack Overflow
or by flanagann
Published on 2010-04-06T11:16:32Z
Indexed on
2010/05/16
22:30 UTC
Read the original article
Hit count: 431
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(); } } }
}
© Stack Overflow or respective owner