R – Flex Tree Custom Tree View

apache-flextree

I have an xml string fetched as a remote object like:

<metadata>  
  <system name="A">  
    <serviceGroup name="SG1">  
      <version id="id1" />  
      <service name="S1"/>  
    </serviceGroup>  
    <serviceGroup name="SG2">  
      <version id="id2" />  
      <serviceGroup name="SG3">  
        <version id="id3" />  
        <service name="S2"/>  
      </serviceGroup>  
    </serviceGroup>  
  </system>  
.
.
.
.
</metadata>

As the xml sample shows, this contains nested servicegroups.
I have to display all the services,and the servicegroups.
And ignore everything else..eg. the version
The services viz. S1 and S2 should be leaf nodes, everything else must be a parent

E.g.
->A
—>SG1
——>S1
—->SG2
——>SG3
———>S2
.
.
.

I tried all kind of things, like using labelFunctions, labelField properties with Tree but it doesn't help. I always end up with un-labelled leaves.

I think I can do this with a ITreeDataDescriptor but not sure how.
I am a flex beginner and the adobe sample didn't help too much ..

I think the above tutorial is far too complex for a beginner.
Would really appreciate if someone can point me to something simpler.

Thanks,
Sandeep

Best Answer

I think your approach may be holding you back a bit. Is it easier to change the default behavior of a control or change the data you are providing to that control?

It is my opinion that you should first of all change the dataprovider of your tree to the XMLList metadata.system.serviceGroup (you may be doing this already, I can't tell without a code example of what you are already trying). Then you should loop through that list and remove the version nodes.

delete yourXMLList.serviceGroup.version[0];

You can search google for better code examples.