1 Reply Latest reply on Feb 27, 2007 6:36 AM by Dzihan

    Tree: Expand all parent items of an item

    Dzihan
      Hello all,

      I'm trying to keep the selected Tree item selected after updating the dataProvider.
      I created an custom Tree component that has a public function called "expandAllParent"
      that i build quite analog to the funcion expandAllChildren() of Flex Tree Class.

      I'm creating a simple Array that contains all parent items of the selected item
      in the right order [ item_lvl0:XMLList, item_lvl1:XMLList, item_lvl2:XMLList, .... , selectedItem:XMLList].

      now I'm looping over this array and do an expandItem() for every single item.
      expandItem() returns before actually creating a list or somethign when
      the internal isBranch() func returns false and that's what happening.

      my Items are not recognized as branches, so its not getting expanded.
      All item are XMLLists and definately have children, so i think it should be a branch..

      Has anyone else tried something similar to this?

      Help would be appreciated.

      PS: Code:

      private function expandAllParent():void
      {
      var i:int = 0;
      var parentItem:Object = tmpArray[0];
      while (parentItem)
      {
      trace(isBranch(parentItem)); // false
      expandItem(parentItem, true);
      parentItem= tmpArray[i++];
      }
      }