It works for me...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
     creationComplete="onCreationComplete()">
     <mx:Script>
         <![CDATA[
             import mx.controls.TextInput;
             import mx.events.DataGridEvent;
             import mx.collections.XMLListCollection;

             private var building_xml:XML = <properties>
                                             <building>Office</building>
                                             <building>Lunch</building>
                                             <building>333</building>
                                             <building>404</building>
                                             </properties>;
             private var building_xmllist:XMLList;
             [Bindable] private var building_xmlcoll:XMLListCollection;

             private function onCreationComplete():void
             {
                 building_xmllist = building_xml.elements();
                 building_xmlcoll = new
XMLListCollection(building_xmllist);
             }

             private function updateData(event:DataGridEvent):void
             {
                 building_xml.elements("*")[event.rowIndex] =
(buildingNumber_dg.itemEditorInstance as TextInput).text;
             }

             private function
getValue(item:Object,grid:DataGridColumn):String
             {
                 return item.toString();
             }
         ]]>
     </mx:Script>
     <mx:DataGrid id="buildingNumber_dg" editable="true"
dataProvider="{building_xmlcoll}" itemEditEnd="updateData(event)">
         <mx:columns>
             <mx:DataGridColumn headerText="Building Number"
labelFunction="getValue" editable="true"/>
         </mx:columns>
     </mx:DataGrid>
</mx:Application>

--- In [email protected], "azona26" <azsl1326-em...@...> wrote:
>
> Thanks for the help. I did try using an itemEditEnd eventlistener. The
issue I was having was that the data value wasn't being changed it was
still the original value.
>
> --- In [email protected], "valdhor" valdhorlists@ wrote:
> >
> > You would need to add an event listener for the itemeditend event.
Then grab the data that was edited and modify the dataprovider.
> >
> >
> > --- In [email protected], "azona26" <azsl1326-email@>
wrote:
> > >
> > > I have an editable datagrid with data being populated from an
> > > XMLListCollection. I am attempting to edit the data in one of the
> > > columns that is using a labelFunction to get its value. This
column does
> > > not have a dataField value. How can I edit the data in the field
and
> > > have the XMLListCollection reflect the updated change correctly as
well
> > > as have the field value change? As it stands now I can change the
data
> > > in the column, however once I leave that datafield it reverts back
to
> > > the original value and the XMLListCollection remains unchanged.
> > >
> > > Here is the DG code:
> > >
> > >      <mx:DataGrid id="buildingNumber_dg" editable="true"
> > > dataProvider="{building_xmlcoll}" >
> > >          <mx:columns>
> > >              <mx:DataGridColumn headerText="Building Number"
> > > labelFunction="getValue" editable="true" />
> > >          </mx:columns>
> > >      </mx:DataGrid>
> > > <mx:Script>
> > >          <![CDATA[
> > >              private function
> > > getValue(item:Object,grid:DataGridColumn):String {
> > >
> > >                  return item.toString();
> > >              }
> > >          ]]>
> > >      </mx:Script>
> > >
> > > XML CODE:
> > > <properties>
> > >          <building>Office</building>
> > >          <building>Lunch</building>
> > >          <building>333</building>
> > >          <building>404</building>
> > > </properties>
> > >
> > > Thanks.
> > >
> >
>

Reply via email to