views:

2261

answers:

2

When I am editing a cell in a dataGrid, the changes are not applied to the dataProvider until I finish editing. Is there a way that I can make the changes appear in the dataProvider whilst editing?

I would assume that the way of doing this would be to subclass the editor I am using, in this case NumericStepper, but I don't know how I would go about it.

Is there some sort of event that I need to trigger?

A: 

If you need to reference anything outside of an itemeditor the way I have done this is through outerDocument.somePublicVar.

So if you need to reference the dataprovider of the datagrid you are editing you can update the var you have binded to the datagrid but it must be public (i think) or you can edit the datagrids dataprovider directly.

Within the item editor you can just catch the change event and update the value in the dataprovider from there. But remember that the end edit item event will be thrown and if your doing any processing in there that might mess with your data provider as well.

Hope this helps.

JustFoo
A: 

if you create your own itemEditor/itemRenderer you can do something like:

<mx:TextInput xmlns:mx="..." change="onChange(event)"
    implements="mx.controls.listClasses.IDropInListItemRenderer">
    <mx:Script>
        <![CDATA[

        import mx.controls.dataGridClasses.DataGridListData;
        import mx.controls.listClasses.BaseListData;
        [Bindable("dataChange")] private var _listData : BaseListData;
        public function get listData():BaseListData
        {
            return _listData;            
        }                   
        public function set listData( value : BaseListData ) : void
        {
            _listData = value;
        }

        private function onChange(event:Event):void
        {
             this.data[ (listData as DataGridListData).dataField ] = this.text;
        }
        ]]>
    </mx:Script>
</mx:TextInput>

hope this helps.

radekg