I did some more tests and debuging, and it turns out the dataprovider of the DG does get updated. But, for some reason - the labelFunction still gets the stale data... When viewing the DG code (and it's super, and it's super's super, etc... :)), it turns out that when the dataprovider gets updated, the data is invalidated to be updated in the next frame - and that's the pitfall I was falling into... :(
I couldn't find a decent solution to this problem, other than using callLater (which I hate)... Sefi On Fri, Dec 26, 2008 at 6:27 PM, Tracy Spratt <[email protected]> wrote: > Hmm, in my experience, re-assigning the dataProvider always results in > full re-rendering of the DataGrid. See if you can narrow down where the > problem is ocurring. Use a bindable var as the dataProvider, or updating > the dp in different ways, or not using labelFunction. > > > > Tracy > > > ------------------------------ > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Sefi Ninio > *Sent:* Thursday, December 25, 2008 2:14 AM > *To:* [email protected] > *Subject:* Re: [flexcoders] Datagrid not updating when dataProvider is > changed. > > > > I'm combining two arrays into a temp arrayCollection and setting the temp > source into a new arrayCollection > dataProvider = new ArrayCollection(tempAC.source); > > This dispatched a CellectionEvent.COLLECTION_CHANGED event with kind=reset, > and should update the DG... > > On Wed, Dec 24, 2008 at 7:08 PM, Tracy Spratt <[email protected]> > wrote: > > How are you updating the data provider items? If you are using the > collection API, like setItemAt(), the necessary events will be dispatched > and the DataGrid will visually update. If you are directly assigning > propety values to individual items, then you will need to call > itemUpdated(item). > > > > Tracy > > > ------------------------------ > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Sefi Ninio > *Sent:* Wednesday, December 24, 2008 5:02 AM > *To:* [email protected] > *Subject:* [flexcoders] Datagrid not updating when dataProvider is > changed. > > > > Hi all. > > I have a wierd situation, hopefully someone here can help. > > I have a DataGrid's dataprovider bound to an myDP ArrayCollection (it is > defined as [Bindable]). Each column in the DG has a labelFunction. > When I set the myDP values for the first time, everything is sweet, the > data is displayed correctly. > > When I update the myDP with new data, however, everything goes wrong. The > labelFunctions still get the stale data (from before the update), and so the > grid shows old data. > I verified the new data is updated to the DG's dataProvider (added a > listener to datagrid for CollectionEvent.COLLECTION_CHANGE - the new data is > updated in the DG dataprovider - checked in event's currentTarget). > > I can't understand why the dataprovider is updated and still the > labelFunction's item:Object contain old data... > > Any ideas anyone? > > Thanks, > Sefi > > > > >

