views:

119

answers:

2

Hi,

how can I refresh the displayed data in a Datagrid when the underlying ArrayCollection changes?

<nmoschitz:dataProvider>
 <mx:HierarchicalData source="{arrCol_groupedData}"
   childrenField="accounts"/>
</nmoschitz:dataProvider>

Calling a simple refresh (like with a simple arraycollection as a dataprovider, or with a refresh on the Grouping Collection) does not work. Also re-assigning the arrayCollection to the Hierarchical Data and then assigning this one again to the Datagrid does not work (even with calling invalidateProperties() or validateNow()).

Any ideas? Someone suggested to extend HierarchicalData and throw a manual change event, but that seems very akward to me.

Thanks, Martin

A: 

I reassigned the whole hierarchical data to the datagrid. However, only the arraycollection needs to be reassigned to the hierarchical data. This solves the issue.

martin
A: 

You can extend HierarchicalData and override the source property setter to throw a CollectionChange event:

package mypackage
{
import mx.collections.HierarchicalData;
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;

public class ModifiedHierarchicalData extends HierarchicalData
{
override public function set source(value:Object):void
{
super.source = value;
var event:CollectionEvent =
new CollectionEvent(CollectionEvent.COLLECTION_CHANGE) ;
event.kind = CollectionEventKind.RESET;
dispatchEvent(event);
}
}
}
Mike Sickler