2 Replies Latest reply on Apr 16, 2009 2:15 PM by mickey3

    xml in flex trees

    mickey3 Level 1

      Hi

       

      It seems like flex tree controls would render the data properly if you have this sort of xml format:

       

      <page label="page 1">

            <page label="sub page" />

            <page label="sub page" />

      </page>

       

      But not if it start to look like this:

       

      <page>

          <label> page 1 </label>

           <extra></extra>

          <page>

              <label> sub page </label>

              <extra></extra>

           </page

      </page>

       

      Would you guys tell me what to do? Should i write my own data descriptor? I tried the labelFunctoin property of the tree control it seems just using that does not suffice.

       

      Thanks.

        • 1. Re: xml in flex trees
          m_hartnett

          Not sure if this is what you want to do but by using xmllistcollection and getting the children it will produce distinct nodes.

           

           

           

           

           

           

           

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application

           

           

          xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()" xmlns:local="*"

          >

           

           

          <mx:Script>

          <![CDATA[

           

           

          import

          mx.collections.XMLListCollection;

           

          [

           

          Bindable]private var

          treeXml:XML =

          <pages>

          <page>

          <label>page 1</label>

          <extra></extra>

          </page>

          <page>

          <label>sub page</label>

          <extra></extra>

          </page>

          </pages>;

           

          [

           

          Bindable]private var treeData:XMLListCollection = new

          XMLListCollection(treeXml.page.children().children());

           

          ]]>

           

           

          </mx:Script>

           

           

           

           

          <mx:Tree id="tree" dataProvider="{treeData}" labelField="label" width="293"></mx:Tree>

           

          </mx:Application>

          • 2. Re: xml in flex trees
            mickey3 Level 1

            hey thanks for trying to help me out, but i solved my problem using custom descriptors, it could probably be the most likeable solution.