2 Replies Latest reply on Nov 22, 2007 6:35 AM by Kishan M V

    Root node

    Zolotoj Level 3
      I am implementing a Tree control into my application. I am setting it to show the root node but it's not shown. My tree data has only one parent for now and it is the root node. So, I am afraid that tree is not showing parents as parents at all.
        • 1. Re: Root node
          Kishan M V Adobe Employee
          Hi,

          I have tried with the below sample

          example.mxml

          <?xml version="1.0" encoding="iso-8859-1"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="xmlServ.send()">
          <mx:Script>
          <![CDATA[
          import mx.collections.*;
          [Bindable]
          public var stuff:XML;
          public function initXML(event:Event):void{
          stuff = event.target.lastResult ;
          tree.dataProvider=stuff;
          }
          ]]>
          </mx:Script>
          <mx:HTTPService id="xmlServ" url="xmlData.xml" result="initXML(event)" resultFormat="e4x"/>
          <mx:Tree id="tree" width="400" labelField="@name" showRoot="true" />
          </mx:Application>

          -------------------------------------------------------------------
          xmlData.xml

          <?xml version="1.0" encoding="windows-1252"?>
          <menu name="BRC Applications" menuid="25" parentid="" link="">
          <menu name="Accidents Reporting" menuid="26" parentid="25" link="accidents">
          </menu>
          <menu name="Personal Injury" menuid="27" parentid="25" link="injuries">
          </menu>
          <menu name="GPS Reports" menuid="28" parentid="25" link="">
          </menu>
          <menu name="Efficiency Testing Administrator" menuid="9" parentid="25" link="safety">
          </menu>
          </menu>

          parent node is shown properly for tree. Can you please provide more details.




          • 2. Re: Root node
            Kishan M V Adobe Employee
            Below sample code also works

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
            <mx:Script>
            <![CDATA[
            import mx.collections.*;
            [Bindable]
            public var xml:XMLListCollection;
            private function initappTree():void
            {
            var xml:XML =
            <menu name="BRC Applications" menuid="25" parentid="" link="">
            <menu name="Accidents Reporting" menuid="26" parentid="25" link="accidents">
            </menu>
            <menu name="Personal Injury" menuid="27" parentid="25" link="injuries">
            </menu>
            <menu name="GPS Reports" menuid="28" parentid="25" link="">
            </menu>
            <menu name="Efficiency Testing Administrator" menuid="9" parentid="25" link="safety">
            </menu>
            </menu> ;
            appTree.dataProvider=xml;
            }
            ]]>
            </mx:Script>
            <mx:Tree id="appTree" creationComplete="initappTree()" width="30%" height="100%" labelField="@name" showRoot="true">
            </mx:Tree>
            </mx:Application>