2 Replies Latest reply on Sep 9, 2011 1:53 PM by Rahul7777

    Selected Index in tree.




      my tree has data coming from back-end, last time user selected tree-node is  in localstorage, so when tree's creationcomplete is completed, i am expanding


      my tree and  specifing like this, but this is not working,  is this the correct way?????


           var nodeName = "<node label=";
           var nodeClose  = "/>"

           for(var i:int=0; i < j=treedp.length; i++)
                           nval= nodeLab[i];    //  nval is xml
                      var item:XML = XML(nodeName + " \""+localstorageObj.getLastselectedTreeitem() +"\""+ nodeClose);
                      treeChannel.selectedItem = item;



      any help.....



        • 1. Re: Selected Index in tree.
          Flex harUI Adobe Employee

          Item is being assigned to a new XML node, not one in the treedp, so the tree

          will not be able to find item in the dataprovider.  When assigning

          selectedItem, we are looking for a matching node reference, we don't compare

          the attributes of the node.


          You can perform an e4x query on the treedp if you save away enough

          information to uniquely identify it.

          1 person found this helpful
          • 2. Re: Selected Index in tree.
            Rahul7777 Level 1

            Hi Alex,

                          i added some attributes to xml to track particular item, Now when i set the selectedItem i am seeing some weird behaviour.


            <mx_internal_uid> attribute is added to the xml item,


            var nodeList:XMLListCollection = treeChannel.dataProvider as XMLListCollection; 

            var nodeLab:XMLList = nodeList.source;

            for(var i:int=0; i < 5; i++)


                nval= nodeLab[i];

                  if(i == treeItem)  // tree Item is int



                           treeChannel.selectedItem = nval.Item.(@channelID==0);

                           trace("tree item is "+ nval.Item.(@channelID==0));






            trace result is:

            <Item label="Name" selectedID="0" channelID="0">




            Actual XML is

            <node label="Header">

            <Item label="Item1" selectedID="0" channelID="0">

            <Item label="Item2" selectedID="0" channelID="1"/>

            <Item label="Item3" selectedID="0" channelID="2"/>

            <Item label="Item4" selectedID="0" channelID="3"/>

            <Item label="Item5" selectedID="0" channelID="4"/>

            <Item label="Item6" selectedID="0" channelID="5"/>


            3 more of this format with different label and id's.

            I want to get rid of this internal uid, as it is displayed in the tree, and selectedItem is not highlighted, unnecessary arrow mark is showed up now.


            any suggestion.