Set editing position for DataGrid
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white">
<mx:Script>
import mx.collections.ArrayCollection;
import mx.events.DataGridEvent;
import mx.validators.EmailValidator;
import mx.controls.TextInput;
[Bindable]
public var myAC:ArrayCollection = new ArrayCollection([
{name:"a", email:"a@i.com"},
{name:"b", email:"b@i.com"}]);
private function onEditEnd(event:DataGridEvent):void
{
if(event.dataField == 'email'){
var fCell:Array=[event.columnIndex,event.rowIndex];
event.preventDefault();
callLater(maintainEdit,fCell);
}
}
private function maintainEdit(colIndex:int,rowIndex:int):void {
var editCell:Object = {columnIndex:colIndex, rowIndex:rowIndex};
dg.editedItemPosition = editCell;
}
</mx:Script>
<mx:DataGrid id="dg" width="350" height="150" dataProvider="{myAC}" itemEditEnd="onEditEnd(event)" editable="true">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" />
<mx:DataGridColumn headerText="EMail" dataField="email" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
Related examples in the same category