4 Replies Latest reply on Aug 31, 2006 11:08 AM by awclemen

    How to expand the tree

    shyguychess
      My tree is not open when it displays. What setting do you change so that all the items in the tree can be shown.
        • 1. Re: How to expand the tree
          deepa subramaniam (adobe) Level 2
          By default, a Tree's branch nodes will appear closed. You can programmatically open a branch node with the public method: expandItem(). expandItem() takes the node that you would like to affect, a boolean indicating whether the node should be opened or closed, and a boolean indicating whether the opening or closing should be animated (by default this is false).

          • 2. Re: How to expand the tree
            shyguychess Level 1
            What do you place as the node object in the first parameter?
            • 3. Re: How to expand the tree
              ur_dtrain Level 1
              You can also call expandChildrenOf(), and pass in your root node. In this case just try passing in the tree's dataProvider: you may have to explicitly cast it into an XML or XMLList object.
              • 4. Re: How to expand the tree
                Level 1
                Here's an example of opening a tree and selecting a certain node:

                <mx:Tree xmlns:mx=" http://www.adobe.com/2006/mxml"
                height="100%"
                width="100%"
                labelField="@label"
                dataDescriptor="{new DefaultDataDescriptor()}"
                creationComplete="creationComplete()">

                <mx:XML id="authenticatedXML" source="pmportal_menu_authenticated.xml"/>
                <mx:XML id="notauthenticatedXML" source="pmportal_menu_notauthenticated.xml"/>

                <mx:Script>
                <![CDATA[
                import mx.controls.treeClasses.DefaultDataDescriptor;
                import mx.collections.XMLListCollection;

                public function setAuth():void
                {
                this.dataProvider = authenticatedXML;
                }

                public function setNotAuth():void
                {
                this.dataProvider = notauthenticatedXML;
                }

                public function creationComplete():void
                {
                var xmlListCollection:XMLListCollection = XMLListCollection(this.dataProvider);
                this.expandItem(xmlListCollection.getItemAt(0), true);
                var xmlListCollection2:XMLListCollection = new XMLListCollection(xmlListCollection.children());
                this.expandItem(xmlListCollection2.getItemAt(3), true);

                var xmlListCollection3:XMLListCollection = new XMLListCollection(xmlListCollection2.source.child("FindCompany"));
                this.selectedItem = xmlListCollection3.getItemAt(0);
                }

                ]]>
                </mx:Script>
                </mx:Tree>


                It's ain't pretty, but it works. If someone has a better way of accessing the nodes, I'm all up for seeing it.

                Thanks,
                Andy