Flex tree 定位

1. 数据源为Object

 

// tree上选择到网元
private function treeLocateNe(treeSource:TreeNode , searchNeName:String):void
{
	if(treeSource.name == searchNeName)
		sourcesTree.selectedItem = treeSource;
	else if(treeSource.children != null)
	{
		sourcesTree.expandChildrenOf(treeSource , true);
		for(var i:int = 0 ; i < treeSource.children.length ; i++)
		{
			treeLocateNe(treeSource.children[i] , searchNeName);
		}
	}
} 

 

 

 

2.数据源为XML

// tree上选择到网元
private function treeLocateNe(treeSource:XMLList , searchNeName:String):void
{				
	for(var i:int=0;i<treeSource.length();i++)
	{
		var childXml:XML =treeSource[i];
		var guid:String = childXml.@labels ;
		if(guid != null && guid == searchNeName)
		{
			//展开所有节点
			for each(var item:XML in sourcesTree.dataProvider)
			sourcesTree.expandChildrenOf(item,true);
			
			sourcesTree.selectedItem = childXml;    //tree上选中节点
			return;
		}else if(sourcesTree.dataDescriptor.isBranch(childXml))//如果有子节点,则递归调用本方法
		{
			treeLocateNe(childXml.children(),searchNeName);
		}
		
	}
} 

 

你可能感兴趣的:(flex tree定位)