Get drag initiator DataGrid from DragEvent : DataGrid Drag Drop « Grid « Flex






Get drag initiator DataGrid from DragEvent

Get drag initiator DataGrid from DragEvent
       


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    
      import mx.collections.ArrayCollection;
      import mx.controls.DataGrid;
      import mx.events.DragEvent;
      import mx.managers.DragManager;
      private function dragCompleteHandler(event:DragEvent):void {
        if(event.action != DragManager.NONE) {
          var grid:DataGrid = DataGrid(event.dragInitiator);
          var data:ArrayCollection = ArrayCollection(grid.dataProvider);
          var item:Object = event.dragSource.dataForFormat("items")[0];
          for(var i:uint = 0; i < data.length; i++) {
            if(data.getItemAt(i).emailId == item.emailId) {
              data.removeItemAt(i);
              break;
            }
          }
        }
      }

  
  </mx:Script>
      <mx:DataGrid dropEnabled="true" dragEnabled="true" dragComplete="dragCompleteHandler(event)">
        <mx:columns>
          <mx:DataGridColumn headerText="From" dataField="from"/>
        </mx:columns>
        <mx:dataProvider>
          <mx:ArrayCollection>
            <mx:Object emailId="0" from="a@a.com"/>
          </mx:ArrayCollection>
        </mx:dataProvider>
      </mx:DataGrid>
      <mx:DataGrid dropEnabled="true" dragEnabled="true" dragComplete="dragCompleteHandler(event)">
        <mx:columns>
          <mx:DataGridColumn headerText="From" dataField="from"/>
        </mx:columns>
      </mx:DataGrid>
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.DataGrid accepting dragging and dropping from another DataGridDataGrid accepting dragging and dropping from another DataGrid
2.Handle dragEnter event for DataGridHandle dragEnter event for DataGrid
3.DataGrid drag enter eventDataGrid drag enter event
4.Drag and drop between DataGridDrag and drop between DataGrid
5.Drag and move between DataGridDrag and move between DataGrid
6.DataGrid drag and dropDataGrid drag and drop
7.drag and move DataGrid itemsdrag and move DataGrid items
8.DataGrid drag and drop eventDataGrid drag and drop event
9.Drag and drop from List to DataGridDrag and drop from List to DataGrid
10.Drag an Image to DataGrid and do calculation based on new added itemDrag an Image to DataGrid and do calculation based on new added item
11.Drag and drop rows from either DataGrid control to the otherDrag and drop rows from either DataGrid control to the other
12.Move or copy data from a Spark List control to an MX DataGrid control by drag and dropMove or copy data from a Spark List control to an MX DataGrid control by drag and drop