xml version="1.0" encoding="utf-8"?>
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
mx:Script>
![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var expenses1:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:2000, Expenses:120, Amount:45},
{Month:"Feb", Profit:1000, Expenses:200, Amount:60},
{Month:"Mar", Profit:1500, Expenses:500, Amount:30}]);
[Bindable]
public var expenses2:ArrayCollection = new ArrayCollection([
{Month:"Apr", Profit:2500, Expenses:150, Amount:55},
{Month:"May", Profit:1800, Expenses:220, Amount:70},
{Month:"Jun", Profit:2700, Expenses:400, Amount:50}]);
private function copyToDg2(evt:Event):void
{
if(dg1.selectedItem!=null)
{
expenses2.addItem(dg1.selectedItem);
//If your looking for move add this below statement
//expenses1.removeItemAt(dg1.selectedIndex);
}
}
private function copyToDg1(evt:Event):void
{
if(dg2.selectedItem!=null)
{
expenses1.addItem(dg2.selectedItem);
//If your looking for move add this below statement
//expenses2.removeItemAt(dg2.selectedIndex);
}
}
]]>
mx:Script>
mx:DataGrid id="dg1" dataProvider="{expenses1}"/>
mx:VBox>
mx:Button label=">>" click="copyToDg2(event)"/>
mx:Button label="<<" click="copyToDg1(event)"/>
mx:VBox>
mx:DataGrid id="dg2" dataProvider="{expenses2}"/>
mx:Application>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment