1 Reply Latest reply on Jun 4, 2009 7:49 AM by Ajith_Cherian

    The tree structure collapses once dynamically populated


      I want to create a tree structure using XML. I have populated the nodes of the XML dynamically. When the user clicks the 'Open' icon of the folder (of the tree), it will dynamically populate the children under it and assign it to the dataProvider of the tree. But once the xml is assigned to the tree, the entire tree structure collapses. I want it to remain open. The code snippet is given below:
















      id="XMLTree0" width="100%" height="100%" alternatingItemColors="[#D1E8F1,#EAF5F9]" color="#2C596B" labelField="@label" creationComplete="initTree();" change="changeEvtProc(event);" itemOpen="itemOpenEvtProc(event);"














      The actionscript which dynamically populates the tree is given below.










      function resultHandler(event:ResultEvent):void {


      if(event.result.length == 0){



      treeData = ArrayCollection(event.result);






      private function convertToXml():void



      var object:Object;


      var level:Number;


      object = treeData[0];

      level = object.node;


      if (level != 1){



          delete checkChildrenList[0];




      for(var i:int=2; i<treeData.length; i++)


      object = treeData[i];


      if (level == 1){

      addNode(rootNode, object, level);



      addNode(selectedNode, object, level);




      treeXMLData =

      new XMLListCollection(rootNode.children());

      XMLTree0.dataProvider = treeXMLData;




        • 1. Re: The tree structure collapses once dynamically populated
          Ajith_Cherian Level 1

          I also tried adding the following code, which checks if the item is open. If not, opens the item by using expandItems. But the issue seems to be that the tree collapses after the code is executed. FYI, there is no code after the ones already put on this post, that is executed.

          var node:XML = XMLTree0.selectedItem as XML;

          var isOpen:Boolean = XMLTree0.isItemOpen(node);

          if (!isOpen){

          XMLTree0.expandItem(node, !isOpen, false, true);