Flex 高级数据网格
我的 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(),但无济于事。
I have an AdvancedDatagrid in my Flex application.
<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>
I dynamically assign columns and grouping and summaries to groupedData GroupingCollection2.
When I filter the datasource and call groupedData.refresh() the grid refreshes fine. But when I load data, and apply no grouping (add no groupings to the GroupingCollection2), the groupedData.Refresh() does not update the grid to show only the filtered in rows. I have also tried calling the grid's own InvalidateList(), to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢你的建议。
我查看了 GroupingCollection2.as 的内部:
因此,出于某种原因,如果没有分组,Adobe 会重置数据源
上,(在我看来)这是一个错误,或者是一个错误的假设。
上面的代码在调用
groupingCollection.refresh()
时被调用,这是刷新 AdvancedDataGrid 上显示的唯一方法(据我所知)
因此,我认为解决方法是始终至少有 1 个分组
在
AdvancedDataGrid
上。不过,有点不受欢迎的限制。Thanks for the suggestion.
I looked inside the GroupingCollection2.as:
So for some reason Adobe does reset the dataSource if there is no grouping
on, which (in my opinion) is a bug, or a bad assumption.
The code above gets called when calling the
groupingCollection.refresh()
,which is the only way of refreshing the display on the
AdvancedDataGrid
(that I am aware of)So, I presume a workaround would be to always have at least 1 grouping
on the
AdvancedDataGrid
. A bit of an undesirable restriction, though.我猜测发生这种情况是因为加载数据时应用于旧 ArrayCollection 的
filterFunction
被清除。我要做的是复制旧的 ArrayCollection 的filterFunction
(以及Sort
如果需要的话),然后在加载数据后重新分配这些属性。这是一个快速(且未经测试)的示例:
My guess is this is happening because the
filterFunction
that was being applied to the oldArrayCollection
is getting wiped out when the data gets loaded. What I would do is make a copy of the old ArrayCollection'sfilterFunction
(andSort
if needed) and then reassign those properties once the data has been loaded.Here's a quick (and untested) example: