Flex:过滤HierarchicalData子行

时间:2012-10-10 18:15:48

标签: flex filter flex4 flex3 hierarchical-data

我有ArrayCollection个对象用作HierarchicalData对象的来源。我的对象看起来大致如下:

ObjectName (String)
SubCollection (ArrayCollection)

我在AdvancedDataGrid中使用HierarchicalData以分组格式显示数据。

我可以使用ArrayCollection过滤filterFunction中的数据。我现在要做的还是过滤SubCollection中的记录,以便只有与过滤器匹配的项目才会显示在AdvancedDataGrid中。

有谁能告诉我如何过滤HierarchicalData中的子行?

1 个答案:

答案 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;
}