Flex:以编程方式扩展 AdvancedDataGrid 树列

发布于 2024-07-17 14:01:12 字数 185 浏览 7 评论 0原文

有谁知道如何以编程方式扩展 Flex 中 AdvancedDataGrid 树列的节点? 如果我使用一棵树,我会使用类似这样的东西:

dataGrid.expandItem(treeNodeObject, true);

但我似乎无权访问 AdvancedDataGrid 中的此属性。

Does anyone know how to programmatically expand the nodes of an AdvancedDataGrid tree column in Flex? If I was using a tree I would use something like this:

dataGrid.expandItem(treeNodeObject, true);

But I don't seem to have access to this property in the AdvancedDataGrid.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉宸 2024-07-24 14:01:12

复制在上述 url 中找到的示例并调用此函数:

private function openMe():void
{
    var obj:Object = gc.getRoot();
    var temp:Object = ListCollectionView(obj).getItemAt(0);
    myADG.expandItem(temp,true);
}

Copy the sample found at the aforementioned url and call this function:

private function openMe():void
{
    var obj:Object = gc.getRoot();
    var temp:Object = ListCollectionView(obj).getItemAt(0);
    myADG.expandItem(temp,true);
}
别想她 2024-07-24 14:01:12

您还可以通过使用游标遍历 dataProvider 来打开节点。 以下是我打开指定级别的所有节点的方法:

    private var dataCursor:IHierarchicalCollectionViewCursor;

    override public function set dataProvider(value:Object):void
    {
        super.dataProvider = value;

        /* The dataProvider property has not been updated at this point, so call 
            commitProperties() so that the HierarchicalData value is available. */
        super.commitProperties();

        if (dataProvider is HierarchicalCollectionView)
            dataCursor = dataProvider.createCursor();
    }

    public function setOpenNodes(numLevels:int = 1):void
    {
        dataCursor.seek(CursorBookmark.FIRST);

        while (!dataCursor.afterLast)
        {
            if (dataCursor.currentDepth < numLevels)
                dataProvider.openNode(dataCursor.current);
            else
                dataProvider.closeNode(dataCursor.current);

            dataCursor.moveNext();
        }

        dataCursor.seek(CursorBookmark.FIRST, verticalScrollPosition);

        // Refresh the data provider to properly display the newly opened nodes
        dataProvider.refresh();
    }

You could also open nodes by iterating through the dataProvider using a cursor. Here is how I open all nodes at a specified level:

    private var dataCursor:IHierarchicalCollectionViewCursor;

    override public function set dataProvider(value:Object):void
    {
        super.dataProvider = value;

        /* The dataProvider property has not been updated at this point, so call 
            commitProperties() so that the HierarchicalData value is available. */
        super.commitProperties();

        if (dataProvider is HierarchicalCollectionView)
            dataCursor = dataProvider.createCursor();
    }

    public function setOpenNodes(numLevels:int = 1):void
    {
        dataCursor.seek(CursorBookmark.FIRST);

        while (!dataCursor.afterLast)
        {
            if (dataCursor.currentDepth < numLevels)
                dataProvider.openNode(dataCursor.current);
            else
                dataProvider.closeNode(dataCursor.current);

            dataCursor.moveNext();
        }

        dataCursor.seek(CursorBookmark.FIRST, verticalScrollPosition);

        // Refresh the data provider to properly display the newly opened nodes
        dataProvider.refresh();
    }
不寐倦长更 2024-07-24 14:01:12

想在此处添加一点,尽管 AdvancedDataGrid 有 expandAll() 方法,但它有一个名为 displayItemsExpanded 的属性,该属性设置为 true将展开所有节点。

为了扩展特定的子项,可以使用 expandChildrenOf()expandItem() 方法,这可以从上面给出的链接中进行验证。

Would like to add here that the AdvancedDataGrid, in spite of having an expandAll() method, has a property called displayItemsExpanded, which set to true will expand all the nodes.

For expanding particular children, the expandChildrenOf() and expandItem() methods can be used, as can be verified from the links given above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文