<?xml version="1.0"?>
<!-- Simple example to demonstrate the HLOCChart control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.DataGridEvent;
import mx.events.ListEvent;
import mx.controls.listClasses.IListItemRenderer;
[Bindable]
private var ac:ArrayCollection=new ArrayCollection([{name: "aaa", sex: 12, mail: "a@sohu.com"}, {name: "nbbb", sex: 17, mail: "cc@sohu.com"}, {name: "cccc", sex: 33, mail: "bbd@sohu.com"}]);
private var obj:Object;
private var nEditIndex:int=-1;
protected function dg_changeHandler(event:ListEvent):void
{
nEditIndex=dg.selectedIndex;
dg.addEventListener(DataGridEvent.ITEM_FOCUS_OUT, ddd);
}
private function ddd(e:DataGridEvent):void
{
obj=e.itemRenderer.data;
obj.mail=obj.name;
}
]]>
</mx:Script>
<mx:DataGrid id="dg"
change="dg_changeHandler(event)"
dataProvider="{ac}"
editable="true">
<mx:columns>
<mx:DataGridColumn headerText="Column 1"
dataField="name"/>
<mx:DataGridColumn headerText="Column 2"
dataField="sex"/>
<mx:DataGridColumn headerText="Column 3"
dataField="mail"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>