4 Replies Latest reply on Mar 12, 2007 7:37 AM by rjarboe

    Dynamic Tree Control

    michael_ramirez44 Level 1
      I am using Flex 2 with iBatis. I have a Remote Object call that returns a Java List collection of objects that have a property that contains another Java List collection of objects. I want to populate a Tree control with this collection of objects and all of the nest collections.
        • 1. Re: Dynamic Tree Control
          peterent Level 2
          What does the data look like when it arrives in Flex? You can use the result event of the RemoteObject call and examine the data. If it is an ArrayCollection of ArrayCollections - thus a heirarchical structure, you can use this in the Tree. Otherwise you will need to use the result event handler to make the structure.

          You will probably need to use a labelFunction to extract the field (or fields) from the records that should be displayed in the tree. If you don't, you'll probably see some funny or missing data.
          • 2. Re: Dynamic Tree Control
            michael_ramirez44 Level 1
            The data from the remote object call is an ArrayCollection of objects. Each object has a property that contains another ArrayCollectio of different objects. I will look into the labelFunction.
            • 3. Re: Dynamic Tree Control
              moyosaned
              Make sure the property is called "children", or els move is to a property called "children", or else you will only see root level.

              For label functions check source of:
              http://labs.flexcoders.nl/?p=23
              • 4. Re: Dynamic Tree Control
                rjarboe
                <?xml version="1.0" encoding="utf-8"?>
                <usermodel>
                ...<departments>
                ......<department>
                .........<index></index>
                .........<departmentprofile>
                ............<id></id>
                ............<name></name>
                ............<description></description>
                .........</departmentprofile>
                .........<managercount></managercount>
                .........<managers>
                ............<manager>
                ...............<index></index>
                ...............<managerprofile>
                ..................<id></id>
                ..................<name></name>
                ..................<description></description>
                ...............</managerprofile>
                ...............<groupcount></groupcount>
                ...............<entities>
                ..................<entity>
                .....................<index></index>
                .....................<entityId></entityId>
                .....................<entityDesc></entityDesc>
                .....................<groupId></groupId>
                .....................<entityNbr></entityNbr>
                .....................<pcmReadingDayGrp></pcmReadingDayGrp>
                ..................</entity>
                ...............</entities>
                ...............<tacentities>
                ..................<tacentity>
                .....................<index></index>
                .....................<tacEntNbr></tacEntNbr>
                .....................<tacEntDesc></tacEntDesc>
                .....................<airlineDivSeq></airlineDivSeq>
                ..................</tacentity>
                ...............</tacentities>
                ...............<groups>
                ..................<group>
                .....................<index></index>
                .....................<groupprofile>
                ........................<id></id>
                ........................<name></name>
                ........................<description></description>
                .....................</groupprofile>
                .....................<usercount></usercount>
                .....................<users>
                ........................<user>
                ...........................<index></index>
                ...........................<userprofile>
                ..............................<id></id>
                ..............................<employeeid></employeeid>
                ..............................<firstname></firstname>
                ..............................<lastname></lastname>
                ..............................<email></email>
                ..............................<departmentprofile>
                .................................<id></id>
                .................................<name></name>
                .................................<description></description>
                ..............................</departmentprofile>
                ..............................<reportingmanagerprofile>
                .................................<id></id>
                .................................<name></name>
                .................................<description></description>
                ..............................</reportingmanagerprofile>
                ..............................<groupprofile>
                .................................<id></id>
                .................................<name></name>
                .................................<description></description>
                ..............................</groupprofile>
                ...........................</userprofile>
                ...........................<accessibleManagers>
                ..............................<managerprofile>
                .................................<id></id>
                .................................<name></name>
                .................................<desc></desc>
                ..............................</managerprofile>
                ...........................</accessibleManagers>
                ...........................<role>
                ..............................<index></index>
                ..............................<id></id>
                ..............................<name></name>
                ..............................<description></description>
                ..............................<userprofiles>
                .................................<userprofile>
                ....................................<id></id>
                ....................................<employeeid></employeeid>
                ....................................<firstname></firstname>
                ....................................<lastname></lastname>
                ....................................<email></email>
                ....................................<departmentprofile>
                .......................................<id></id>
                .......................................<name></name>
                .......................................<description></description>
                ....................................</departmentprofile>
                ....................................<reportingmanagerprofile>
                .......................................<id></id>
                .......................................<name></name>
                .......................................<description></description>
                ....................................</reportingmanagerprofile>
                ....................................<groupprofile>
                .......................................<id></id>
                .......................................<name></name>
                .......................................<description></description>
                ....................................</groupprofile>
                .................................</userprofile>
                ..............................</userprofiles>
                ..............................<rightsmatrix>
                .................................<screens>
                ....................................<screen>
                .......................................<index></index>
                .......................................<id></id>
                .......................................<name></name>
                .......................................<description></description>
                .......................................<accessible></accessible>
                .......................................<componentCount></componentCount>
                .......................................<components>
                ..........................................<component>
                .............................................<index></index>
                .............................................<id></id>
                .............................................<name></name>
                .............................................<description></description>
                .............................................<required></required>
                .............................................<roleAccess></roleAccess>
                .............................................<userCustomAccess></userCustomAccess>
                .............................................<modified></modified>
                ..........................................</component>
                .......................................</components>
                ....................................</screen>
                .................................</screens>
                ..............................</rightsmatrix>
                ...........................</role>
                ........................</user>
                .....................</users>
                ..................</group>
                ...............</groups>
                ............</manager>
                .........</managers>
                ......</department>
                ...</departments>
                </usermodel>

                Here is an example of my data structure as it is returned from my remote object. NOTE: Each tag is actually a Value Object. Plural tags are ArrayCollections.

                What I need is to ignore most of the data for now, and only use:
                Department
                ->Manager
                -->Group
                --->User

                as the heirarchy of my tree.