Search Flex Components Free

Custom Search

December 27, 2007

Flex Drag and Drop Source Code Example:

Flex Drag and Drop Grid Example Source Code Example:

Creat a New mxml file:
dragging .mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundAlpha="0"
horizontalAlign="center"
creationComplete="initApp()">

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;
import mx.managers.DragManager;
import mx.events.DragEvent;

[Bindable]
public var dataSrc:ArrayCollection;

[Bindable]
public var dataDest:ArrayCollection;

public function initApp():void
{
srv.send();
dataDest = new ArrayCollection();
}

]]>

</mx:Script>

<mx:HTTPService id="srv" url="../assets/catalog.xml"
result="dataSrc = new ArrayCollection(srv.lastResult.catalog.product)"/>

<mx:Text width="100%" textAlign="center">
<mx:text>
You can drag and drop rows from one datagrid to the other.
Use the Ctrl or Shift keys to select multiple rows in a datagrid.
While dragging, press the CTRL key to copy rows from one datagrid to the other (rows are moved by default).
</mx:text>
</mx:Text>

<mx:HBox width="100%" height="100%" horizontalGap="10">

<mx:DataGrid dataProvider="{dataSrc}"
width="100%" height="100%"
allowMultipleSelection="true"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="price" headerText="Price"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid dataProvider="{dataDest}"
width="100%" height="100%"
allowMultipleSelection="true"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="price" headerText="Price"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>

</mx:HBox>

</mx:Application>

Related Flex Tutorials