I wanted to give you a status update on my investigations with this problem. First, I wanted to thank both of you who replied - I've learned a lot about collections in no small part because of your help.
In addition to the things you pointed out that I was doing wrong, the core problem turned out to be related to the custom itemRenderer and not to the XMLListCollection. My custom itemRenderer was looking up the ID value in the list and returning the Name associated with that ID value. Unfortunately this itemRenderer was not always invalidating the display list. I've patched the problem and things now seem to be working a lot better. Thanks again for all your help! --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > You are sure you are using the Collection API exclusively? And not > doing any direct assignments of values to item porperties? For example: > > var oCurrentItem:MyItem = myAC.getItemAt(0); > > oCurrentItem.myProperty = "myValue"; //direct assignment does not > cause UI to update > > > > If you are doing any of the above, then you need to call itemUpdated() > after the assignment. > > > > Tracy > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Tim Hoff > Sent: Saturday, October 18, 2008 5:14 PM > To: [email protected] > Subject: [flexcoders] Re: Crazy DataGrid display of XMLListCollection > > > > Hi, > > If the dataProvider is [Bindable], the DataGrid should reflect the > changes to the dataProvider; when the dataProvider is changed. For the > itemRenderer question, here's one way to update the display list: > > override public function set data(value:Object):void > { > if (value != null) > { > super.data = value; > > // do something conditional > > super.invalidateDisplayList(); > } > } > > However, since there isn't any conditional changes to the itemRenderer, > this would be unnecessary. > > -TH > > --- In [email protected], "edlueze" <edlueze@> wrote: > > > > I am trying to update the display of an XMLListCollection in a > > 2-column DataGrid but I am getting crazy results. > > > > The XMLListCollection contains following data: > > > > <item><order>1</order><content>AAA</content></item> > > <item><order>2</order><content>BBB</content></item> > > <item><order>3</order><content>CCC</content></item> > > <item><order>4</order><content>DDD</content></item> > > > > I am providing the user with two buttons to raise or lower the content > > within the XMLListCollection. For example, if the user selects the > > 'CCC' row and clicks the 'RaiseButton' then the XMLListCollection will > > change to: > > > > <item><order>1</order><content>AAA</content></item> > > <item><order>2</order><content>CCC</content></item> > > <item><order>3</order><content>BBB</content></item> > > <item><order>4</order><content>DDD</content></item> > > > > Note that the order field is recalculated to always be increasing - > > and the content field is reordered. > > > > I've created a new Class that extends XMLListCollection with two new > > functions: 'raiseItem' and 'lowerItem'. These new functions take > > copies of the XML for the 'BBB' row and the 'CCC' row, and then rely > > upon the XMLListCollection function 'setItemAt' to do the reordering. > > The underlying XMLList is then sent to a server for processing. This > > seems to work perfectly and traces of the XMLListCollection always > > seem correct. > > > > Unfortunately the XMLListCollection display in the DataGrid fails to > > keep up with changes in the underlying data. > > > > I've tried lots of combinations of 'invalidateDisplayList', > > 'invalidateList', 'validateNow', 'refresh' and 'sort'. I've tried > > nullifying and resetting the 'dataProvider'. And I've tried copying > > over the entire list XMLListCollection one element at a time into a > > new display version of the XMLListCollection. Often I get duplicate > > display rows, but sometimes I get the entire list displayed in > reverse?! > > > > I suspect the itemRenderers aren't getting the message that they > > should be refreshing (one column uses the 'labelFunction' and the > > other has a not-too-complicated custom itemRenderer). > > > > How would I go about invalidating the display of *each* itemRenderer > > individually? What else should I try?? > > > > Thanks! > > >

