Thank you very much for the help! Here is what I wrote to solve this
problem:
private function handleItemEdit(event:DataGridEvent):void
{
event.preventDefault();
var itemData:XML = event.itemRenderer.data as
XML;
var newData:Object =
itemEditorInstance[this.columns[event.columnIndex].editorDataField];
itemData.setChildren(newData);
this.destroyItemEditor();
}
--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> The DG default code assumes that you are pulling properties for display
> and stuffing them on edit. Your label functions are not simply property
> pullers so you'll need to customize an ITEM_EDIT_END handler, call
> preventDefault() and stuff it yourself.
>
>
>
> -Alex
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of arieljake
> Sent: Thursday, May 31, 2007 10:53 AM
> To: [email protected]
> Subject: [flexcoders] Re: DataGrid edits with XMLListCollection
> dataprovider
>
>
>
> Update:
>
> I do not think this is something to be done with ItemRenderer or
> ItemEditor. I have tracked this to the DataGrid itself. There is a
> line there that says:
>
> data[property] = newValue;
>
> This leads to entries in the data like:
>
> <fields>
> <field1>
> <text>my new value</text>
> </field1>
> </fields>
>
> when the dataField="text"
>
> OR
>
> <fields>
> <field1>
> <null>my new value</null>
> </field1>
> </fields>
>
> when the dataField is empty.
>
> Text is not a property of an XML object, so there is no setter. And
> setChildren does not work as a property, only a method.
>
> How else can one get the DataGrid to save the data like:
>
> <fields>
> <field1>my new value</field1>
> </fields>
>
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , Ariel Jakobovits <arieljake@>
> wrote:
> >
> > I have this file:
> >
> > <fields>
> > <field1>value1</field1>
> > <field2>value2</field2>
> > </fields>
> >
> > output in these columns:
> >
> > <mx:columns>
> > <mx:DataGridColumn headerText="Field" width="100"
> editable="false" labelFunction="getFieldLabel" />
> > <mx:DataGridColumn headerText="Value" editable="true"
> labelFunction="getValueLabel" />
> > </mx:columns>
> >
> > with these label functions:
> >
> > private function getFieldLabel(data:Object,
> column:DataGridColumn):String
> > {
> > return XML(data).localName().toString();
> > }
> > private function getValueLabel(data:Object,
> column:DataGridColumn):String
> > {
> > return XML(data).text().toString();
> > }
> >
> > Question: if I want to edit the value column, how do I set the text
> () property of an XML node?
> >
>