Hey Alex, Here is the code.
Thanks, Marcio N. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="myInitialize(event)"> <mx:Script> <![CDATA[ import mx.collections.ICollectionView; import mx.events.CollectionEventKind; import mx.events.PropertyChangeEvent; import mx.events.CollectionEvent; [Bindable] private var DATAPACKET: XML = <dados> <row> <data>17/01/2007</data> <evento>POSICIONAMENTO DE OS</evento> <usuario>MARCOSA</usuario> <consulta></consulta> </row> </dados> public function myInitialize (event:Event):void { ((ICollectionView) (grid.dataProvider)).addEventListener (CollectionEvent.COLLECTION_CHANGE, changeData); } public function changeData(event: CollectionEvent): void { //Alert.show(event.items.toString()); //Alert.show(event.toString()); //trace(DATAPACKET); //trace(event.items.length); //trace(grid.selectedIndex); trace(event.type); trace(event.location); trace(event.oldLocation); trace('size = '+event.items.length); if (event.items.length > 0) { if (event.items[0] is PropertyChangeEvent) { var pce: PropertyChangeEvent = event.items[0] as PropertyChangeEvent; trace('type ='+pce.kind); if (pce.kind == CollectionEventKind.UPDATE) { trace ('field = '+pce.property); // nome do campo trace ('source = '+pce.source); trace ('target = '+pce.target); trace ('value = '+pce.source[pce.property]); // linha trace ('oldvalue = '+pce.oldValue); trace ('newValue = '+pce.newValue); //DATAPACKET.dados.row.{pce.property} = pce.source {pce.property}; //trace (pce.source[pce.property]); trace('grid index = '+grid.selectedIndex); // trace (DATAPACKET.row[grid.selectedIndex]); } //Alert.show (PropertyChangeEvent(event.items[0]).newValue.toString()); } } //Alert.show(event.toString()); } ]]> </mx:Script> <mx:DataGrid id="grid" editable="true" width="100%" height="100%" x="0" y="0" dataProvider="{DATAPACKET.row}" selectedIndex="0"> <mx:columns> <mx:DataGridColumn width="100" headerText="Data" dataField="data"/> <mx:DataGridColumn width="300" headerText="Evento" dataField="evento"/> <mx:DataGridColumn width="100" headerText="Usuário" dataField="usuario"/> <mx:DataGridColumn width="100" headerText="Consulta" dataField="consulta"/> </mx:columns> </mx:DataGrid> </mx:Application> --- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote: > > Please post a sample app > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Marcio Napoli > Sent: Tuesday, August 28, 2007 4:42 AM > To: [email protected] > Subject: [flexcoders] Re: Help > > > > Hey Alex, > > I have tryed already! But in all scenarios the XML (DATAPACKET) is > updated. So, i can't get the old values. > > Thanks, > Marcio > > --- In [email protected] <mailto:flexcoders% 40yahoogroups.com> > , "Alex Harui" <aharui@> wrote: > > > > Try tracing using toXMLString(). > > > > ________________________________ > > > > From: [email protected] <mailto:flexcoders% 40yahoogroups.com> > > [mailto:[email protected] <mailto:flexcoders% 40yahoogroups.com> > ] On > > Behalf Of Marcio Napoli > > Sent: Monday, August 27, 2007 11:36 AM > > To: [email protected] <mailto:flexcoders% 40yahoogroups.com> > > Subject: [flexcoders] Re: Help > > > > > > > > > > Hey Alex, > > > > As any change in DataGrid will modify my XML everything could be > > changed in XML. However my XML has the following structure: > > "date", "event" and "user" and this nodes are DataGridColumn. > > > > So when i change one cell in DataGrid the event "changeData" is > fired. > > > > Could u help me ? > > > > Thanks, > > Marcio N. > > > > --- In [email protected] > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > , "Alex Harui" <aharui@> wrote: > > > > > > What did you change in the XML? > > > > > > ________________________________ > > > > > > From: [email protected] > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > > > [mailto:[email protected] > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > ] On > > > Behalf Of Marcio Napoli > > > Sent: Wednesday, August 22, 2007 7:00 AM > > > To: [email protected] <mailto:flexcoders% 40yahoogroups.com> > <mailto:flexcoders% > 40yahoogroups.com> > > > Subject: [flexcoders] Help > > > > > > > > > > > > Hi All, > > > > > > I am having problems with collection, when i change the value of > > one > > > registry to a new value i lost the old one. For example: > > > > > > [Bindable] private var DATAPACKET: XML = <data> > > > <row> > > > <date>17/01/2007</date> > > > <event>Event 01</event> > > > <user>MARCOSA</user> > > > </row> > > > </data> > > > > > > ((ICollectionView) (grid.dataProvider)).addEventListener > > > (CollectionEvent.COLLECTION_CHANGE, changeData); > > > > > > public function changeData(event: CollectionEvent): void { > > > if (event.items.length > 0) { > > > if (event.items[0] as PropertyChangeEvent) { > > > var pce: PropertyChangeEvent = event.items[0] as > > > PropertyChangeEvent; > > > if (pce.kind == CollectionEventKind.UPDATE) { > > > trace(pce.source); > > > trace > > > (pce.target); > > > trace(pce.property); > > > trace > > > (pce.oldValue); > > > trace(pce.newValue); > > > trace(DATAPACKET.row[grid.selectedIndex]); > > > } > > > } > > > } > > > } > > > > > > In my sample the attributes "pce.oldValue" and "pce.newValue" are > > > null. > > > The "pce.source" is with new value and my var "datapacket" > already > > > updated. > > > So, how can i get the old value? > > > > > > Thanks, > > > Marcio Napoli > > > napoli@ <mailto:napoli%40stela.org.br> > > > > > >

