我有一个 ArrayCollection
对象,用作 HierarchicalData
对象的源。我的对象大致如下所示:
ObjectName (String)
SubCollection (ArrayCollection)
我正在 AdvancedDataGrid 中使用 HierarchicalData
以分组格式显示数据。
我可以使用 filterFunction
过滤 ArrayCollection
中的数据。我现在想做的是过滤 SubCollection
中的记录,以便只有与过滤器匹配的项目才会显示在 AdvancedDataGrid
中。
谁能告诉我如何过滤 HierarchicalData
中的子行?
最佳答案
This answer不是对你的问题的直接答案,但它应该有助于了解一些背景知识。本质上,我的处境与您相同,我需要根据我拥有的父节点类型来显示特定的数据集。
在这种情况下,从覆盖 HierarchicalData.getChildren(node:Object):Object
开始,这将使您能够过滤第一级子级,并且还使您能够调用针对任何第 n 级子级的过滤方法。
然后,您可以使用扩展类作为 ADG 的源。
伪代码示例:
Class MyCollection extends HierarchicalData
override public function getChildren(node:Object):Object
{
if (node is a TopLevelObject)
(node.children as ArrayCollection).filterFunction = filterSub;
node.children.refresh();
else if (node is a SubCollectionObject)
(node.children as ArrayCollection).filterFunction = filterGrandChildren;
node.children.refresh();
// - OR -
//a more complex process of allowing the sub-node to determine it's filter
return node.filterSubCollectionGrandChildren();
return node;
}
关于apache-flex - 弹性 : Filter HierarchicalData child rows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12825752/