Does this work for you if the node node in the rightTree is visible? It does in the sample I just tried. However, if the node you are attempting to expand is not visible (its parent is closed) then the expand does not work.
This can be coded around several ways, depending on what you want to do. Here is an example of sync'd trees. Beware though, it either shows up bugs in the Tree, or there are bugs in my code, since some operations cause rows of the tree to blank out. Tracy <?xml version="1.0" encoding="utf-8"?> <!-- SyncTree example. --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="100%" creationComplete="initApp()"> <mx:Script><![CDATA[ import mx.events.TreeEvent; import mx.utils.ObjectUtil; [Bindable] public var selectedNode:Object; [Bindable] public var myXML:XML; private function initApp():void { selectedNode = tree1.dataProvider[0]; tree1.selectedItem = selectedNode; callLater(expandTreeNode, [tree1.selectedItem]); }//initApp private function expandTreeNode(myXMLNode:XML):void{ tree1.expandItem(myXMLNode,true,false); } private function onChangeTree1(oEvent:Event):void { var xmlSelected:XML = XML(tree1.selectedItem) //var sId:String = [EMAIL PROTECTED]; //var xmlNodeToDelete:XML = treeData..node.(@label == sId); tree2.selectedItem = xmlSelected; } private function onOpenClose(oEvent:mx.events.TreeEvent, bOpen:Boolean):void { var xmlNode:XML = XML(oEvent.item); tree2.expandItem(xmlNode,bOpen,true); }// ]]></mx:Script> <mx:XMLList id="treeData"> <node label="root"> <node label="Mail Box"> <node label="Inbox"> <node label="Marketing"/> <node label="Personal"/> </node> <node label="Outbox"> <node label="Professional"/> </node> <node label="Spam"/> <node label="Sent"/> </node> <node label="Saved"> <node label="Work"> <node label="Hardware"/> <node label="Software"/> </node> <node label="Personal"> <node label="Home"/> <node label="Shopping"> <node label="Christmas"/> <node label="Birthday"/> </node> </node> </node> </node> </mx:XMLList> <mx:Panel title="Synchronized Treel Example" height="100%" width="100%" paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> <mx:HDividedBox width="100%" height="100%"> <mx:Tree id="tree1" width="50%" height="100%" labelField="@label" showRoot="false" dataProvider="{treeData}" change="onChangeTree1(event)" itemOpen="onOpenClose(event, true)" itemClose="onOpenClose(event, false)" /> <mx:Tree id="tree2" width="50%" height="100%" labelField="@label" showRoot="false" dataProvider="{treeData}" /> </mx:HDividedBox> </mx:Panel> </mx:Application> ________________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Harald Kucharek Sent: Wednesday, March 28, 2007 9:42 AM To: [email protected] Subject: [flexcoders] Connecting two tree views Hi, I'm new to Flex and want the following: I have two Tree views side by side, based on the same XML-datasource. When I click one node in the left tree, I want the node holding the same data to be expanded on the right tree. Naive :-) Code: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" pageTitle="Tree Sync"> <mx:Script> <![CDATA[ public function treeItemClicked(event:Event):void { rightTree.expandItem(leftTree.selectedItem, true); } ]]> </mx:Script> <mx:XML id="dataSet" source="data/tree.xml" xmlns=""/> <mx:Panel x="10" y="10" width="465" height="459" layout="absolute"> <mx:HDividedBox x="10" y="10" height="399" width="425"> <mx:Tree width="100%" height="100%" id="leftTree" dataProvider="{dataSet}" showRoot="false" labelField="@label" itemClick="treeItemClicked(event)" ></mx:Tree> <mx:Tree width="100%" height="100%" id="rightTree" dataProvider="{dataSet}" showRoot="false" labelField="@label"></mx:Tree> </mx:HDividedBox> </mx:Panel> </mx:Application> Of course, rightTree.expandItem(leftTree.selectedItem, true); isn't working as I hoped it may. Is there an easy solution for my task? Thanks in advance, Harald

