我有ArrayCollection
个对象用作HierarchicalData
对象的来源。我的对象看起来大致如下:
ObjectName (String)
SubCollection (ArrayCollection)
我在AdvancedDataGrid中使用HierarchicalData
以分组格式显示数据。
我可以使用ArrayCollection
过滤filterFunction
中的数据。我现在要做的还是过滤SubCollection
中的记录,以便只有与过滤器匹配的项目才会显示在AdvancedDataGrid
中。
有谁能告诉我如何过滤HierarchicalData
中的子行?
答案 0 :(得分:2)
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;
}