I finally found time to look into this. I would like you to file a bug with your test case and send me the bug number. I'm not sure we can actually fix this given the way XML change notification works, but we might be able to make it a little better.
The issue is that the collection is watching each node (<row>) tag, but you are actually editing the <evento> or <usario> tags which are not watched for changes and thus oldvalue/newvalue are not computed. In XML, an UPDATE event can mean that something changed in my child nodes. We could add watching for the child nodes, but we may not want to due to memory and performance overhead. The second update comes when the datagrid finishes editing. I'm pretty sure that's a bug. It should know that changes to XML are watched, but it doesn't think so and forces dispatching of another event. There might be some case where a change needs forcing, but I won't know until we dig that far. For now, unless you expect to change the nodes in other ways outside of the datagrid, get the itemEditEnd event and use it to check oldvalue/newvalue. -Alex ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Marcio Napoli Sent: Tuesday, August 28, 2007 12:19 PM To: [email protected] Subject: [flexcoders] Re: Help Alex, Its simple. Please, run the application in debug mode and change any cell in DataGrid. The event "changeData" is fired twice. None attribute has the old value. Thanks for you help! Marcio N. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > I'll try to take a look later. What are the steps to recreate the problem? > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Marcio Napoli > Sent: Tuesday, August 28, 2007 10:33 AM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: Help > > > > 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 > <http://www.adobe.com/2006/mxml> <http://www.adobe.com/2006/mxml <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] <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders% 40yahoogroups.com> , "Alex Harui" <aharui@> wrote: > > > > Please post a sample app > > > > > > > > ________________________________ > > > > 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: Tuesday, August 28, 2007 4:42 AM > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > <mailto:flexcoders% 40yahoogroups.com> > > 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> > > <mailto:flexcoders% 40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > , "Alex Harui" <aharui@> wrote: > > > > > > Try tracing using toXMLString(). > > > > > > ________________________________ > > > > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > <mailto:flexcoders% 40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > > > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> > > <mailto:flexcoders% 40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups.com> > > ] On > > > Behalf Of Marcio Napoli > > > Sent: Monday, August 27, 2007 11:36 AM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > <mailto:flexcoders% 40yahoogroups.com> <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> > > <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:flexcoders%40yahoogroups.com> <mailto:flexcoders% > > 40yahoogroups.com> > > > > > > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> > > > <mailto:flexcoders% 40yahoogroups.com> > > <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> <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> > > > > > > > > > >

