我的Flex应用程序中有一个AdvancedDatagrid。
<mx:AdvancedDataGrid id="reportGrid" creationComplete="groupedData.refresh()" width="100%" height="100%" variableRowHeight="true">
<mx:dataProvider>
<mx:GroupingCollection2 id="groupedData" source="{reportData}"/>
</mx:dataProvider>
</mx:AdvancedDataGrid>我为groupedData GroupingCollection2动态分配列、分组和摘要。当我过滤数据源并调用groupedData.refresh()时,网格刷新得很好。但是,当我加载数据,并且没有应用分组(不向GroupingCollection2添加分组)时,groupedData.Refresh()不会更新网格,只在行中显示经过筛选的内容。我还尝试过调用网格自己的InvalidateList(),但没有成功。
发布于 2011-06-26 16:23:56
谢谢你的建议。
我查看了GroupingCollection2.as:
// return if no grouping or groupingFields are supplied
if (!grouping || grouping.fields.length < 1 )
{
super.source = source;
// dispatch collection change event of kind reset.
resetEvent =
new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
resetEvent.kind = CollectionEventKind.RESET;
dispatchEvent(resetEvent);
return true;
}因此,出于某种原因,如果没有分组,Adobe会重置dataSource,这(在我看来)是一个错误,或者是一个糟糕的假设。
上面的代码在调用groupingCollection.refresh()时被调用,这是刷新AdvancedDataGrid上的显示的唯一方法(据我所知)
因此,我假设一种解决方法是在AdvancedDataGrid上始终至少有1个分组。然而,这是一个不受欢迎的限制。
发布于 2011-06-23 22:02:23
我的猜测是,这是因为当数据加载时,应用于旧ArrayCollection的filterFunction正在被清除。我要做的是复制旧的ArrayCollection的filterFunction (如果需要,还可以复制Sort ),然后在加载数据后重新分配这些属性。
下面是一个简单的(未经测试的)示例:
public function loadData(myData:ArrayCollection):void
{
var filter:Function = reportData.filterFunction;
reportData = myData;
reportData.filterFunction = filter;
reportData.refresh();
}https://stackoverflow.com/questions/6452750
复制相似问题