Thanks, Jon. Your example works for me, but I also need to add "message"
leaf elements, and exclude those from the tree.

i.e.

<mx:XMLList  id="folders">
  <folders>
  <folder name="account1">
   <folder name="Inbox">
       <message name="Greetings">
       </message>
     </folder>
  </folder>
  </folders>
</mx:XMLList>


They're included in the data grid like so:

<mx:DataGrid width="100%" height="100%"
dataProvider="{folders..folder.(@name == 'Inbox').message}">

Even though this is a mock-up, I'd like to use the same XML structure for
both controls, and see how much interactivity I can mock up just using e4x
to manipulate the XMLList object. Obviously, I will eventually have to
change the datagrid to use the selected tree node rather than the above
predicate.


On 5/18/07, Jon Bradley <[EMAIL PROTECTED]> wrote:

  Not sure what you're really asking, how to do a nested tree? You need to
use XMLList instead of XML (I don't think it dynamically casts the
dataProvider to a XMLList if you provide it just XML).

You can swap out label with name and use the same labelField convention.

good luck,

- jon

Here's a tested example:

<mx:XMLList id="myTreeData">
<node label="Accounts">
    <node label="First Account">
        <node label="Inbox">
            <node label="Flexcoders"/>
            <node label="Flashcoders"/>
            <node label="Flashnewbie"/>
        </node>
        <node label="Send Items">             <node label="Nested Tree e4x
"/>
        </node>
        <node label="Trash">
            <node label="Flashnewbie"/>
        </node>
 </node>
    <node label="Second Account">         <node label="Inbox">
            <node label="New Messages"/>
            <node label="Flagged Items"/>
            <node label="Attachments"/>
            <node label="All Mail"/>
        </node>
        <node label="Send Items">
            <node label="Tree Data Provider with e4x"/>
        </node>
        <node label="Trash">             <node label="Lame Yahoo HTML
emails"/>
        </node>
 </node>
</node>
</mx:XMLList>


On May 18, 2007, at 11:12 AM, Richard Rodseth wrote:

I'm whipping up a mock-up of a UI much like a mail client (folder tree
+ data grid), using XML dummy data. I've got the rows of the data grid
populating with an e4x predicate, and I have the tree populating with
data like this:

<mx:Tree x="0" y="0" width="100%" height="100%"
dataProvider="{folders}" labelField="@name" showRoot="false"
defaultLeafIcon="@Embed(source='Assets.swf',
symbol='TreeFolderClosed')"></mx:Tree>

<mx:XML id="folders">
<folders>
<account name="account1">
<folder name="Inbox">
</folder>
<folder name="Sent Items">
</folder>
</account>
<account name="account2">
<folder name="Inbox">
</folder>
<folder name="Sent Items">
</folder>
</account>
</folders>


Reply via email to