I'm sure that there are a number of ways you can do this, among them
coding a data descriptor class that implements the IDataDescriptor
(http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=about_dataproviders_057_15.html)
or renaming your Item.data field to Item.children so the
DefaultDataDescriptor would work with your class.
package
{
import mx.collections.ArrayCollection;
[Bindable]
public class Item {
public var name:String;
public var category:String;
//public var data:ArrayCollection;
public var children:ArrayCollection;
}
}
We recently ran into a situation where we wanted our Tree to use an
array of objects returned from a CFC as the data provider and still
take advantage of the auto conversion of remoting.
We weren't in a position to have the CFC return a
property named "children" and let the DefaultDataDescriptor handle it,
so what we ended up doing was adding a get function (property) named
children that returned the ArrayCollection being returned by the CFC
under a different name:
package {
import mx.collections.ArrayCollection;
[Bindable]
[RemoteClass(alias="SomeSite.cfc.AuthorVO")]
public class AuthorVO {
public var name:String = null;
public var publisher:String = null;
public var books:Array = null;
public function get children():ArrayCollection {
if (books== null) return null;
var ret:ArrayCollection = new ArrayCollection();
ret.source = books;
return ret;
}
}
}
This doesn't break the auto conversion of the CFC to the Flex class
and could be used for your situation as well:
package
{
import mx.collections.ArrayCollection;
[Bindable]
public class Item {
public var name:String;
public var category:String;
public var data:ArrayCollection;
public function get children():ArrayCollection {
return data;
}
}
}
Hope this helps!
--- In [email protected], "fb6668" <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a data structure which looks a little like this:
>
> items:ArrayCollection is an array of objects with class Item:
>
> Item:
> name:String
> category:String
> data:ArrayCollection is an array of objects with class Detail:
>
> Detail:
> name:String
> type:String //either "income" or "detail"
> val:Object
>
> So, I would like to create a tree with dataProvider="{items}" that
> looks like:
> -Item[name]
> >Detail[name]
> >Detail[name]
> >Detail[name]
> -Item[name]
> >Detail[name]
> >Detail[name]
>
> Now, if the data was in XML or just a basic ArrayCollection, this
> would be straightforward, but not sure how to accomplish it with my
> custom classes?
>
> Sorry about the simple question, quite new to Flex!
>
> Thanks for your help,
>
> F
>