20090601

DataGrid - Extracting edited Value from DataGridEvent




private function saveValue(event:DataGridEvent) : void
{
if(event.reason == DataGridEventReason.CANCELLED)
return;
var newValue : String = TextInput(event.currentTarget.itemEditorInstance).text;
var prevCellValue : String = myDataGrid.selectedItem[event.dataField];

if( prevCellValue == newValue)
return;
Alert.show("New value :: "+newValue);
}

...
...

<mx:DataGrid id="myDataGrid" width="100%" dataProvider="{defCreativeVals}" editable="true" itemEditEnd="{saveValue(event)}">
<mx:columns>
<mx:DataGridColumn headerText="Column" id="colColumn" editable="false" dataField="name"/>
<mx:DataGridColumn headerText="Value" id="colValue" editable="true" dataField="value" />
</mx:columns>
</mx:DataGrid>

1 comment:

gs said...

Thanks. This is helpful.