嗨朋友这是我的要求:
当我双击“搜索”选项卡中的一个项目时,应该在“测试组树”选项卡中打开(展开)该特定项目。搜索选项卡中的项目是列表,测试组树中的项目是 TreeItem。据我所知,在其他选项卡中展开树项目的唯一方法是使用其标签名称(唯一)。
在这里,我使用下面提到的代码来实现我的要求。现在,当我双击“搜索”选项卡中的项目时,“测试组树”选项卡正确打开,但 SelectedItem 未展开(按预期在另一个选项卡中打开 - 只有“测试组树”选项卡打开,没有其他反应)。请帮我实现我的要求。
private function TSTree_itemDoubleClick(event:ListEvent):void{
var selectedItem: TSTreeItem = TSTreeItem(TSTreeTestGroup.getSelectedFolderItem());
this.TSTreeTestGroup.tabMain.selectedIndex=0; // Here i am trying to open a next tab(it works)
//var selectedSampleItem: TSTreeItem = PLTreeItem(TSTreeTestGroup.treTree.getChildByName(selectedItem.label));
TestGroupTree(TestGroupManager(this).TSTreeTestGroup).loadPartialTreeItem(selectedItem); // Here i actually want to refresh the particular tree item
TestGroupTree(TestGroupManager(this).TSTreeTestGroup).treTree.expandItem(selectedItem,true,false); // here i am trying to expand the particular tree item
//TestGroupManager(TestGroupTree(TSTree(event.currentTarget).parentDocument).parentDocument).TSTreeTestGroup.treTree.expandItem(selectedItem, true, false);
//TestGroupManager(TestGroupTree(TSTree(event.currentTarget).parentDocument).parentDocument).TSTreeTestGroup.loadPartialTreeItem(this.TSTreeTestGroup.treTree.getChildByName(selectedItem.label);
// in the following i am tryin to get the TreeItemName and expand it accordingly
TestGroupTree(TestGroupManager(this).TSTreeTestGroup).treTree.expandItem(this.TSTreeTestGroup.treTree.getChildByName(selectedItem.label), true, true);
}
<?xml version="1.0"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" implements="integras.TS.component.TSTreeComponent"
show="Component_Show();"
remove="Component_Remove();" >
<mx:TabNavigator id="tabMain" change="tabMain_Change();" styleName="plTitleWindowTabNavigator" creationPolicy="all" >
<mx:Canvas label="Test Group Tree">
<ns1:TSTree dataProvider="{dpTree}" updateComplete="treTree_UpdateComplete();" iconFunction="getTreeIcon" labelField="label" iconField="icon" showRoot="false" allowMultipleSelection="true" id="treTree" doubleClickEnabled="true" itemDoubleClick="treTree_ItemDoubleClick(event);" itemClick="treTree_ItemClick(event);" itemOpen="treTree_ItemOpen(event);" >
</ns1:TSTree>
</mx:Canvas>
<mx:Canvas label="Search" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Canvas>
<mx:HRule/>
<mx:List dataProvider="{dpSearch}" dragEnabled="false" labelField="label" iconField="icon" id="lstSearch" doubleClickEnabled="true" itemDoubleClick="lstSearch_ItemDoubleClick(event);" itemClick="lstSearch_ItemClick(event);">
</mx:List>
</mx:Canvas>
</mx:Canvas>
</mx:TabNavigator>
</mx:Box>
提前致谢。如果您有任何疑问,请告诉我。