topical media & game development
professional-flex-code-07-CellData.mx
professional-flex-code-07-CellData.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.TextInput;
import mx.events.DataGridEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var productsAC:ArrayCollection = new ArrayCollection
(
[
{Product: "iPod", Price: 249},
{Product: "iMac", Price: 1299},
{Product: "MacBook Pro", Price: 1999}
]
);
private function getCellInfo(event:DataGridEvent):void
{
var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
var newVal:String = myEditor.text;
var oldVal:String = event.currentTarget.editedItemRenderer.data[event.dataField];
cellInfo.text = "cell edited. \n";
cellInfo.text += "Row, column: " + event.rowIndex + ", " + event.columnIndex + "\n";
cellInfo.text += "New value: " + newVal + "\n";
cellInfo.text += "Old value: " + oldVal;
}
]]>
</mx:Script>
<mx:TextArea id="cellInfo" width="300" height="150" />
<mx:DataGrid dataProvider="{productsAC}" editable="true" itemEditEnd="getCellInfo(event)">
<mx:columns>
<mx:DataGridColumn dataField="Product" />
<mx:DataGridColumn dataField="Price" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.