Flex: Extending AdvancedDataGrid Tree Column Programmatically

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

dataGrid.expandItem(treeNodeObject, true);

But I do not have access to this property in AdvancedDataGrid.

+3
source share
4 answers

Copy the sample found at the above 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);
}
+5
source

, 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();
    }
+2

I would like to add that, despite the presence of the method expandAll(), the AdvancedDataGrid has a property with the name displayItemsExpandedthat is set to trueexpand all nodes.

To expand individual children, methods can be used expandChildrenOf()and expandItem()that can be checked at the above links.

+2
source

Source: https://habr.com/ru/post/1706735/


All Articles