Correct me if I'm wrong, but the data descriptor is essentially a node visitor. 
 It will tell the tree how to render a given node.  However, it has no way of 
adding nodes to previous nodes (ie groups).  Take this scenario:

[
{group:"animal", item:"cat"},
{group:"fruit", item:"apple"},
{group:"animal", item:"dog"},
{group:"fruit", item:"orange}
]

Using the ITreeDataDescriptor, you'd end up with a tree structure like this:
-animal
--cat
-fruit
--apple
-animal
--dog
-fruit
--orange

when what you want is this:
-animal
--cat
--dog
-fruit
--apple
--orange

I just discovered ITreeDataDescriptor2.  It looks like that might handle that 
scenario?


--- In flexcoders@yahoogroups.com, Alex Harui <aha...@...> wrote:
>
> The goal of IDataDescriptor was to turn just about anything into a heirarchy. 
>  You could have the following data structure:
> 
> Class AddressBookEntry
> {
>     var name:String
>     var MobilePhone:String
>     var HomePhone:String
>     var WorkPhone:String
> }
> 
> And turn it into a tree by having the getChildren call return an 
> ArrayCollection made up of the 3 phone number slots.
> 
> 
> 
> On 4/6/10 5:26 PM, "Jeff" <britton.j...@...> wrote:
> 
> 
> 
> 
> 
> 
> 
> 
> I cant vouch for the ILog Elixir stuff.  There might be an easy way to do it. 
>  Assuming that doesnt suit your needs, I think you may need to massage your 
> data a bit because I dont think the data descriptor alone will give you what 
> you're looking for.
> 
> I'm assuming this is basically your desired tree structure:
> -group1
> --item
> --item
> -group2
> --item
> --item
> -group3
> --item
> --item
> 
> Your probably going to need to put your data into a collection that looks 
> like this:
> 
> var myCollection:ArrayCollection = new ArrayCollection([
> {group:"group1", items:[item,item,item]},
> {group:"group2", items:[item,item,item]},
> {group:"group3", items:[item,item,item]}
> ]);
> 
> Then, you can use a dataDescriptor to tell the tree what properties of the 
> item object you want to display.  The tree is packaged with a default 
> dataDescriptor, so your data either has to conform to its conventions to 
> display properly or you have to override it.
> 
> Implementing a very basic ITreeDataDescriptor and putting your debugger on it 
> will give you valuable insight as to how the Tree component traverses a given 
> data provider.  You can then tell the tree how to display the objects in your 
> collection.  Hope that helps.
> 
> To anyone out there, iff there's an easier way to do it with the ILog stuff, 
> I'd appreciate a link to it.  Thanks.
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> "cuttenv" <cuttenv@> wrote:
> >
> > You could use a grouping Collection to group the data. If you check out the 
> > ILog Exlir stuff they have a bunch of demos on how to do this.
> >
> > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> > Alex Harui <aharui@> wrote:
> > >
> > > The dataDescriptor's purpose is to allow you to create a hierarchy out of 
> > > flat data.
> > >
> > >
> > > On 4/6/10 8:42 AM, "Phil Boissiere" <deletedfromyoutube@> wrote:
> > >
> > >
> > >
> > >
> > >
> > >
> > > Thanks, Oleg, Jeff.
> > >
> > > In reality the thing that comes back after querying my database is an 
> > > ArrayCollection of strongly typed objects (value objects?). These objects 
> > > have a linear (non-hierarchical) structure but I want to use one of the 
> > > properties (the "group" property) for the parent nodes in a Tree 
> > > component.
> > >
> > > Should I be looking at creating a custom data descriptor or a custom 
> > > object that implements the ICollectionView interface (does that mean 
> > > create a custom Tree component?).
> > >
> > > I just want to make sure I'm doing the right thing, since either approach 
> > > seems to involve quite a bit of ActionScript.
> > >
> > > Thanks again.
> > >
> > >
> > > --- On Tue, 4/6/10, Jeff <britton.jeff@> wrote:
> > >
> > > From: Jeff <britton.jeff@>
> > > Subject: [flexcoders] Re: Using an ArrayCollection to populate a Tree 
> > > component
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> > > Date: Tuesday, April 6, 2010, 7:18 AM
> > >
> > >      You can also create a custom data descriptor and set the 
> > > dataDescriptor property of the tree component.  See http://livedocs. 
> > > adobe.com/ flex/3/html/ help.html? content=about_ dataproviders_ 6.html 
> > > <http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_6.html>
> > >
> > > --- In flexcod...@yahoogro ups.com 
> > > </mc/compose?to=flexcoders%40yahoogroups.com> , Oleg Sivokon 
> > > <olegsivokon@ ...> wrote:
> > > >
> > > > The best way would be to implement your own ICollectionView, however, 
> > > > this
> > > > would be a complex task.
> > > > For your example, I'd do it like so:
> > > >
> > > > private var ac:ArrayCollection = new ArrayCollection( [
> > > >             { "Animals": ["dog", "cat"],
> > > >             { "Fruits": ["orange", "apple"] }
> > > >             ]);
> > > >
> > > >
> > > > Best.
> > > >
> > > > Oleg
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Alex Harui
> > > Flex SDK Team
> > > Adobe System, Inc.
> > > http://blogs.adobe.com/aharui
> > >
> >
> 
> 
> 
> 
> 
> 
> --
> Alex Harui
> Flex SDK Team
> Adobe System, Inc.
> http://blogs.adobe.com/aharui
>


Reply via email to