Get data from DataGrid in drag enter event
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
import mx.events.DragEvent;
import mx.managers.DragManager;
[Bindable]
public var myAC:ArrayCollection = new ArrayCollection([
{name:"A", email:"a@domain.com", isActive:true},
{name:"B", email:"b@domain.com", isActive:false},
{name:"C", email:"c@domain.com", isActive:true}]);
public function handleDragEnter(event:DragEvent):void
{
var arItems:Array= event.dragSource.dataForFormat("items") as Array;
for (var i:int = 0; i < arItems.length; i++){
trace(arItems[i].isActive);
}
}
</mx:Script>
<mx:DataGrid id="dgSource" dataProvider="{myAC}" dragEnabled="true"
dragMoveEnabled="true">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Contact Name" width="300" />
<mx:DataGridColumn dataField="email" headerText="E-Mail" width="200" />
<mx:DataGridColumn dataField="isActive" headerText="Active" width="75" />
</mx:columns>
</mx:DataGrid>
<mx:DataGrid id="dgTarget" dropEnabled="true" dragEnter="handleDragEnter(event)">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Contact Name" width="300" />
<mx:DataGridColumn dataField="email" headerText="E-Mail" width="200" />
<mx:DataGridColumn dataField="isActive" headerText="Active" width="75" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
Related examples in the same category