Thursday, April 1, 2010

xml in flex trees

Hi

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

%26lt;page label=''page 1''%26gt;

聽聽聽聽聽 %26lt;page label=''sub page'' /%26gt;

聽聽聽聽聽 %26lt;page label=''sub page'' /%26gt;

%26lt;/page%26gt;

But not if it start to look like this:

%26lt;page%26gt;

聽聽聽 %26lt;label%26gt; page 1 %26lt;/label%26gt;

聽聽聽聽 %26lt;extra%26gt;%26lt;/extra%26gt;

聽聽聽 %26lt;page%26gt;

聽聽聽聽聽聽聽 %26lt;label%26gt; sub page %26lt;/label%26gt;

聽聽聽聽聽聽聽 %26lt;extra%26gt;%26lt;/extra%26gt;

聽聽聽聽 %26lt;/page

%26lt;/page%26gt;

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.

xml in flex trees

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

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;

%26lt;mx:Application

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

%26gt;

%26lt;mx:Script%26gt;

%26lt;![CDATA[

import

mx.collections.XMLListCollection;

[

Bindable]private var

treeXml:XML =

%26lt;pages%26gt;

%26lt;page%26gt;

%26lt;label%26gt;page 1%26lt;/label%26gt;

%26lt;extra%26gt;%26lt;/extra%26gt;

%26lt;/page%26gt;

%26lt;page%26gt;

%26lt;label%26gt;sub page%26lt;/label%26gt;

%26lt;extra%26gt;%26lt;/extra%26gt;

%26lt;/page%26gt;

%26lt;/pages%26gt;;

[

Bindable]private var treeData:XMLListCollection = new

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

]]%26gt;

%26lt;/mx:Script%26gt;

%26lt;mx:Tree id=''tree'' dataProvider=''{treeData}'' labelField=''label'' width=''293''%26gt;%26lt;/mx:Tree%26gt;

%26lt;/mx:Application%26gt;

xml in flex trees

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

  • makeup video
  • No comments:

    Post a Comment