How to retrieve the pre edited value of the cell of a datagrid to an itemeditor in a flex

1.8k Views Asked by At

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.

2

There are 2 best solutions below

0
On

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.

0
On

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.