Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 在flex中使用标签名或其他字段展开树项_Actionscript 3_Apache Flex_Tree_Expand - Fatal编程技术网

Actionscript 3 在flex中使用标签名或其他字段展开树项

Actionscript 3 在flex中使用标签名或其他字段展开树项,actionscript-3,apache-flex,tree,expand,Actionscript 3,Apache Flex,Tree,Expand,嗨,朋友们,这是我的要求: 当我双击“搜索”选项卡中的某个项目时,该项目应在“测试组树”选项卡中打开(展开)。 搜索选项卡中的项目是一个列表,测试组树中的项目是一个树项目。据我所知,在“其他”选项卡中展开树项目的唯一方法是使用其标签名(唯一) 在这里,我使用了下面提到的代码来实现我的需求。目前,当我双击“搜索”选项卡中的项目时,“测试组树”选项卡将正确打开,但SelectedItem未展开(在另一个选项卡中按预期打开,只有测试组树选项卡会打开,其他情况不会发生)。 请帮我达到我的要求 priva

嗨,朋友们,这是我的要求:

当我双击“搜索”选项卡中的某个项目时,该项目应在“测试组树”选项卡中打开(展开)。 搜索选项卡中的项目是一个列表测试组树中的项目是一个树项目。据我所知,在“其他”选项卡中展开树项目的唯一方法是使用其标签名(唯一)

在这里,我使用了下面提到的代码来实现我的需求。目前,当我双击“搜索”选项卡中的项目时,“测试组树”选项卡将正确打开,但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>
私有函数TSTree\u itemDoubleClick(事件:ListEvent):void{
var selectedItem:TSTreeItem=TSTreeItem(TSTreeTestGroup.getSelectedFolderItem());
this.TSTreeTestGroup.tabMain.selectedIndex=0;//这里我试图打开下一个选项卡(它可以工作)
//var selectedSampleItem:TSTreeItem=PLTreeItem(TSTreeTestGroup.tretretree.getChildByName(selectedItem.label));
TestGroupTree(TestGroupManager(this).TSTreeTestGroup.loadPartialTreeItem(selectedItem);//这里我实际上想刷新特定的树项
TestGroupTree(TestGroupManager(this).TSTreeTestGroup.tretretree.expandItem(selectedItem,true,false);//这里我试图展开特定的树项
//TestGroupManager(TestGroupTree(TSTree(event.currentTarget.parentDocument.parentDocument).TSTreeTestGroup.tretretree.expandItem)(selectedItem,true,false);
//TestGroupManager(TestGroupTree(TSTree(event.currentTarget.parentDocument.parentDocument).TSTreeTestGroup.loadPartialTreeItem(this.TSTreeTestGroup.tretretree.getChildByName)(selectedItem.label);
//在下面的文章中,我尝试获取TreeItemName并相应地展开它
TestGroupTree(TestGroupManager(this.TSTreeTestGroup.tretretree.expandItem)(this.TSTreeTestGroup.tretretree.getChildByName(selectedItem.label)),true,true;
}

提前感谢。如果您有任何疑问,请告诉我。

如果找到展开节点,请尝试在树中搜索所选项目。我认为问题可能是您传递到树以进行展开的所选项目

检查此示例是否有助于您

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" verticalAlign="middle">
    <mx:Script>
        <![CDATA[
            import mx.messaging.management.Attribute;
            import mx.events.ListEvent;

            import mx.controls.Alert;
            import mx.collections.XMLListCollection;

            [Bindable]
            private var searchResult:XMLList;
            private var searchResultIndex:uint = 0;

            private function findByLabel(event:Event):void
            {
                var searchStr:String = List(event.currentTarget).selectedItem.@label;
                tabMain.selectedIndex = 0;
                tree.openItems = [];
                //xmlDP.descendants().(@label == List(evt.currentTarget).selectedItem.@label)[0]
                searchResult = xmlDP.descendants().(@label.toLowerCase().search(searchStr.toLowerCase()) > -1);
                searchResultIndex = 0;
                if (searchResult[searchResultIndex] != undefined)
                    expandNode(searchResult[searchResultIndex]);
            }

            private function expandNode(xmlNode:XML):void
            {
                while (xmlNode.parent() != null) {
                    xmlNode = xmlNode.parent();
                    tree.expandItem(xmlNode, true, false);
                }
            }
      ]]>
    </mx:Script>

    <!-- Sample tree data -->
     <mx:XML id="xmlDP">
        <root>
                <node label="Parent 1">
                    <node label="Child 1"/>
                    <node label="Child 2">
                        <node label="Grandchild 1"/>
                        <node label="Grandchild 2"/>
                    </node>
                    <node label="Child 3"/>
                    <node label="Child 4"/>
                    <node label="Child 5">
                        <node label="Grandchild 1"/>
                        <node label="Grandchild 2"/>
                    </node>
                </node>
            </root>
    </mx:XML>

    <mx:XMLListCollection id="xmlMenuList" source="{xmlDP.*}"/>


    <mx:XMLList id="listData">
          <data>
            <node label="Parent 1" />
            <node label="Child 1"/>
            <node label="Child 2"/>
            <node label="Grandchild 1"/>
            <node label="Grandchild 2" />
            <node label="Child 3"/>
            <node label="Child 4"/>
            <node label="Child 5"/>
            <node label="Grandchild 1"/>
            <node label="Grandchild 2" />
        </data>
    </mx:XMLList>


    <mx:TabNavigator id="tabMain" creationPolicy="all" width="100%" >
            <mx:Canvas label="Test Group Tree">
                <mx:Tree dataProvider="{xmlMenuList}" labelField="@label" iconField="icon" showRoot="false"  
                         allowMultipleSelection="true" id="tree" doubleClickEnabled="true" width="100%">
                </mx:Tree>
            </mx:Canvas>
            <mx:Canvas label="Search" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                <mx:Canvas width="100%">
                    <mx:HRule/>
                    <mx:List dataProvider="{listData.node}"  dragEnabled="false" labelField="@label" id="lstSearch"
                             width="100%" itemClick="findByLabel(event)">
                    </mx:List>
                </mx:Canvas>
            </mx:Canvas>
    </mx:TabNavigator>


</mx:Application>

-1);
searchResultIndex=0;
if(searchResult[searchResultIndex]!=未定义)
expandNode(searchResult[searchResultIndex]);
}
私有函数expandNode(xmlNode:XML):void
{
while(xmlNode.parent()!=null){
xmlNode=xmlNode.parent();
expandItem(xmlNode,true,false);
}
}
]]>