0 Replies Latest reply on May 30, 2007 1:10 PM by QRius99

    Current node in Tree control

    QRius99
      Hi. I have a flex tree control being data-provided from an xml file.
      As the user is going deeper into the tree, I want to display the path
      they took to reach there with each time they click. Like this:

      USA > California > Los Angeles

      Any ideas?

      My code looks like this so far:

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="778" height="652"
      borderStyle="solid" layout="absolute" backgroundColor="#ffffff">

      <mx:Script>
      <![CDATA[
      private var seltxt:String = "";
      // Initialize the data provider for the Tree.
      private function initApp():void {
      catTree.dataProvider = treeDP;
      }

      private function selectCat() :void {
      catname.text = "";
      var node:XML = XML(catTree.selectedItem);
      seltxt = node.parent().@name
      if (seltxt != '') {
      seltxt = node.parent().@name + ' > ' + node.@name;
      }
      else {
      seltxt = node.@name;
      }



      catname.text = seltxt;
      }
      ]]>
      </mx:Script>

      <mx:XML id="treeDP" source="cat.xml" />
      <mx:VBox>
      <mx:HBox width="100%">
      <mx:Label x="451" y="33" text="Selected Category:" fontWeight="bold"/>
      <mx:Text x="451" y="59" id="catname" text=""/>
      </mx:HBox>

      <mx:HBox width="100%" height="100%">
      <mx:Panel width="100%" height="100%" layout="absolute">
      <mx:Tree id="catTree"
      height="450" width="450"
      showRoot="false"
      labelField="@name"
      dragEnabled="false"
      dropEnabled="false"
      dragMoveEnabled="false"
      allowMultipleSelection="false"
      creationComplete="initApp();" x="0"
      itemClick="selectCat()"/>

      </mx:Panel>
      </mx:HBox>
      </mx:VBox>
      </mx:Application>

      Thanks,
      A