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();
}
4条答案
按热度按时间0x6upsns1#
AdvancedDataGrid也有一个expandItem()方法:
http://livedocs.adobe.com/flex/3/langref/mx/controls/AdvancedDataGrid.html#expandItem()
baubqpgj2#
复制在上述url中找到的示例,并调用此函数:
q8l4jmvw3#
您也可以使用游标遍历dataProvider来打开节点。下面是我如何打开指定级别的所有节点:
du7egjpx4#
在此需要补充的是,尽管AdvancedDataGrid具有
expandAll()
方法,但它有一个名为displayItemsExpanded
的属性,将该属性设置为true
将展开所有节点。为了展开特定的子对象,可以使用
expandChildrenOf()
和expandItem()
方法,这可以从上面给出的链接中得到验证。