Reputation: 989
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
Upvotes: 0
Views: 2748
Reputation: 8561
Just expand the root node and close again programmatically will refresh the UI.
if(!dGGrid.isItemOpen(itemData)){
dGGrid.expandItem(itemData,true);
dGGrid.expandItem(itemData,false)
}else{
dGGrid.expandItem(itemData,false);
dGGrid.expandItem(itemData,true);
}
Upvotes: 0
Reputation: 11
You could try refreshing the arrayCollection and then calling invalidateList() on the grid
Upvotes: 1
Reputation: 34461
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);
}
}
}
Upvotes: 0
Reputation: 989
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.
Upvotes: 0