1 Reply Latest reply on Nov 6, 2011 10:26 PM by Flex harUI

    Flex Tree does not selecting (highlight) the selectedIndices

    srip1188

      have an array of items that should be selected in my tree control. As you can see from my code below,I bind this array to the selectedIndices property of the tree. The selectedItems are not properly selecting in tree(selecting some other items and always root is selected).Flex seems to "ignore" my items (highlights some other indices). Am I missing something?

      Perhaps I'm going about this in wrong way?

      Thanks for your help!

      My XMLList:-

      <fx:Declarations>
             
      <!-- Place non-visual elements (e.g., services, value objects) here -->
             
      <fx:XMLList id="XMLList">
             
      <node>
                 
      <node name="max">
                     
      <node name="Emanuele"
                           
      surname="Tatti" age="23" wage="1200"/>
                     
      <node name="Francesco"
                           
      surname="Rapana " age="22" wage="1000"/>
                     
      <node name="Constantin"
                           
      surname="Moldovanu" age="23" wage="1200"/>
                     
      <node name="Marco"
                           
      surname="Casario" age="29" wage="1500">
                         
      <node name="Marco"
                               
      surname="Casario" age="29" wage="1500">
                             
      <node name="Marco"
                                   
      surname="Casario" age="29" wage="1500">
                                 
      <node name="Marco"
                                       
      surname="Casario" age="29" wage="1500">
                                 
      </node>
                             
      </node>
                         
      </node>                
                     
      </node>
                 
      </node>

             
      </node>
             
      </fx:XMLList>
      </fx:Declarations>

      My Action Script Function:-

      public function select_tree():Void 
      {
      tree
      .validateNow();
      var allItems:Array = new Array();
      for(var n:Int =2;n<7;n+2)      
      {
              allItems
      [n]=n; // o/p- 2,4,6
      }

      tree
      .selectedIndices = allItems1;   //2,4,6 items should select ,but 0,2,4,5 are selected why?
           
      }

      *****My MXML:-*****
      <mx:Button id="btn" label="Find Unmatch Nodes" width="221" height="30" click="select_tree()"/>



      <mx:Tree id="tree"  right="10" top="54" bottom="10" width="49.5%" dataProvider="{XMLList}"
          fontFamily
      ="Verdana" fontSize="11" showScrollTips="true"
          allowMultipleSelection
      ="true"
          alternatingItemColors
      ="[#F5F5F5]"
          labelField
      ="@label" selectionColor="#ECF335" showRoot="false"/>