1 Reply Latest reply on Dec 10, 2009 4:12 PM by PeakDigital

    Add branch node to Tree at runtime?

    PeakDigital Level 1

      I need to be able to allow users to add both "branches" and "leaves" to a Tree. I am trying to do this without utilizing external inputs. In one of the Help articles it said 'leaf nodes can be added at runtime' but didn't say anything about branches, and the example used an external TextInput to type the name for the new leaf node.

       

      I built this function that runs without error, but does not alter the Tree's dataProvider:

      public function addNewBranchNode():void
                  {
                  var xmlNewNode:XML=new XML(<parentNode></parentNode>);
                  xmlNewNode.@ID=0;
                  xmlNewNode.@Title="Click and type the title you want";
                  xmlNewNode.@isBranch=true;
                  xmlNewNode.@NodeType="root";
                  
                  var intNewPos:int=_primaryListManager.treePrimaryListManager.dataProvider.length-2;
                  _primaryListManager.treePrimaryListManager.dataProvider.addChildAt(xmlNewNode,intNewPos);
                  }

       

      I have my "add new" button as the final item in the dataProvider, so I want the new branch node to be inserted directly above it.

       

      Any suggestions?

       

      Thanks.

      Paul