3 Replies Latest reply on Feb 28, 2007 1:45 PM by theLoggerGuy

    Hiding tree dataprovider nodes.

    ctzn99
      Hello once again,

      I'm a little stuck on something... i've got xml that looks like

      <template label="company">
      <tab label="general">
      <section label="address">
      <field label="street">
      <width>50</width>
      <height>50</width>
      </field>
      </section>
      </tab>
      </template>

      I then use that xml as the dataprovider for my tree, all is great BUT, i don't want the tree to display anything below field. I'm a little stuck on how to do that. I found this snippet from someone at Adobe but I think it confused me more than helped me

      "The Tree uses the ITreeDataDescriptor interface to pull items out of the data, so a custom impl could filter based on whatever criteria you'd like. Specifically you'll want to write a custom getChildren to return only the children that you want displayed. You may also need isBranch and hasChildren but the defaults may work for you."

      Based on that it sounds like I can test for the xml node local name while the tree is rendering and only render 1 of the 4 that I want to show...

      Can anyone point me in the direction to a working example (with source)? Or have some pointers that might help?

      Regards,
      Zach Brown
        • 1. Re: Hiding tree dataprovider nodes.
          theLoggerGuy Level 1
          The easiest way to get around this issue is to reformat your XML to something like this:
          <template label="company">
          <tab label="general">
          <section label="address">
          <field label="street" width="50" height="50"/>
          </section>
          </tab>
          </template>

          Changing the 'width' and 'height' elements to attributes changes the way the Tree handles the data. Just make sure that you understand that your tree has a labelField predefined to "label".

          eg., <mx:Tree dataProvider="BlahBlah" labelField="@label"/>

          This is why other attributes wont show up in the tree. That particular issue had me scratching my head for some time :-(
          • 2. Re: Hiding tree dataprovider nodes.
            ctzn99 Level 1
            Reformatting isn't really an option. Well, I suppose it is but it isn't really one I want to consider as the data is quite a bit more complicated than what I presented. Each field has additional tags below (as in my example) but, further to that tags below the field tag have tags below them. There is a complex permissions and restrictions scheme that each field adheres to depending on the user and or type of user. Additionally there are field flags wich describe the type of content in the field, each field can have anywhere from 1 to x type flags.

            <template label="company">
            <tab label="general">
            <section label="address">
            <field label="street">
            <contentTypes>
            <type>General Content</type>
            <type>Address Information</type>
            </contentTypes>
            <userTypes>
            <type>1</type>
            </userTypes>
            <explicitPermissions>
            <userID>1</userID>
            </explicitPermissions>
            <width>50</width>
            <height>50</width>
            </field>
            </section>
            </tab>
            </template>

            Essentiall i've got very structured data thats perfect for a heirechal model view but, i only want to display some of that heirarchy in my tree. The rest of the data is used elsewhere in the same editor that I'm building and using the same xml for databinding.

            Thanks for the suggestions though, it's already something that I have spent some serious time thinking about.

            Regards,
            Zach
            • 3. Re: Hiding tree dataprovider nodes.
              theLoggerGuy Level 1
              My next suggestion is to create a second data structure using your existing XML as the source. So you have one for the data and one for the tree. The E4X model makes it really easy to create XML structures.

              If you think of another way then please post it.