views:

668

answers:

2

I wrote a custom item editor for a datagrid in flex. My question is how to retrieve the pre-edited value of the datagrid cell after the item editor initializes and also in the custom item editors code.

A: 

I don't think it is possible to get the old value once you are in the item editor. I would do this manually by listening to the "itemEditBeginning" event and keeping a variable with the value of the cell. You can then reference that value through the "parent", "parentDocument" or "outerDocument" properties in the item editor, depending on whether you are using an inline item editor or a separate class.

Christophe Herreman
A: 

In the "itemEditEnd" event you can access the old value as:

var oldValue:String = event.currentTarget.dataProvider[event.rowIndex].VALUE_FIELD;

and the new value as:

var txtControl:mx.controls.TextInput = event.currentTarget.itemEditorInstance as mx.controls.TextInput;
var newValue:String = txtControl.text;

If you are using a custom itemRenderer you need to change "mx.controls.TextInput" for your custom itemRenderer.
Good luck!

Fabi1816