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 valida开发者_如何学运维teNow()).
Any ideas? Someone suggested to extend HierarchicalData and throw a manual change event, but that seems very akward to me.
Thanks, Martin
You could try refreshing the arrayCollection and then calling invalidateList() on the grid
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.
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);
}
}
}
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);
}
精彩评论