tree自动展开节点

//拖拽时展开节点==========================
private function dragOverHandler(event:DragEvent):void
{
var currNodeOver : TreeItemRenderer= TreeItemRenderer(event.currentTarget.indexToItemRenderer(event.currentTarget.calculateDropIndex(event)));

if (currNodeOver !=null)
{
if(Tree(event.currentTarget).dataDescriptor.isBranch(currNodeOver.data) == true)
{
if (Tree(event.currentTarget).isItemOpen(currNodeOver.data)==false)
Tree(event.currentTarget).expandItem(currNodeOver.data,true,true);
}
}
}

然后把 Tree 的 dragOver 设定为 dragOverHandler ,dragOver=”dragOverHandler(event)” 。然后就OK了。


******************************************************************
//itemClick时展开节点================
private function itemClickHandler(event: ListEvent): void{
var targetTree: Tree = Tree(event.target);
var selIndex = targetTree.getItemIndex(targetTree.selectedItem);
var itemRender: IListItemRenderer = targetTree.indexToItemRenderer(selIndex);

targetTree.expandItem(itemRender.data, true, true, true);
}

你可能感兴趣的:(tree)