Hi, I will try this tonight and see how it goes. It seems with RemoteObjects you can't have the resultFormat = e4x like you can with an HTTPService call. With e4x its much easier to get at the xml from what I understand.
-Malik --- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > You will need a labelFunction() to define the label for complex xml. > > Tracy > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of jensen.axel > Sent: Wednesday, February 07, 2007 3:33 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: Populate Tree with data from a query? > > > > Malik, > > I'm not sure if your xml has to be formatted that way, depending on > what your working with(if your getting your xml from a service that is > already in place, and other code is already using that formatted xml) > then you would be forced to use the xml as is... > > but if at all possible, try to format your xml this way > > <companies> > <company name="Macrosoft"> > <contact name="Bill Bates"/> > <contact name="Mark Smith"/> > </company> > <company name="Oracle Corporation"> > <contact name="Larry Jobs"/> > </company> > </companies> > > now you can use the label="@name" in your mx:Tree > > there are also some things you will definitely want to look at in the > example on my blog... > > This issue was pondering me, so i made and example to see what was > going on, and your right it is acting weird in the tree... so anyway > check out the example... it's at the bottom of the page on my blog... > it says "CLICK HERE TO VIEW THE EXAMPLE" > > http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex- > as-xml > <http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex > -as-xml> > > I'm always looking for more subscribers and comments, so please > subscribe... I usually put up and example on almost every post, unless > i'm just throwing up a link i want to remember. > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > , "malik_robinson" > <Malik_Robinson@> wrote: > > > > Hi Tracy, > > > > When I do a trace as you indicated. I see this: > > > > <companies> > > <company name="Macrosoft"> > > <contact> > > <displayName>Bill Bates</displayName> > > </contact> > > <contact> > > <displayName>Mark Smith</displayName> > > </contact> > > </company> > > <company name="Oracle Corporation"> > > <contact> > > <displayName>Larry Jobs</displayName> > > </contact> > > </company> > > </companies> > > > > And this is what I see when my tree is rendered also. > > > > -Malik > > > > > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <tspratt@> wrote: > > > > > > Have you determined that model.treeData contains valid xml? > > > (trace(treeData.toXMLString())) If it does, then the tree should > work > > > like you have it. You will need to set the "labelField" property for > > > the label, or use a labelFunction if the data you want for the label > > is > > > not a top-level porperty/attribute of the item node. > > > > > > > > > > > > Also, I am not familiar with RemoteObject, so this may not apply, > but > > > you may need to set resultFormat="e4x". Also, if the data service > was > > > HTTPService, I would do the result handler like this: > > > > > > public function result( event:ResultEvent ):void { > > > var xmlResult:XML = XML(event.result); > > > > > > trace(xmlResult.toXMLString()); > > > model.treeData = xmlResult; > > > } > > > > > > > > > > > > if you see good xml but are still having difficulty, take the model > > > class out of the picture and assign the dataProvider directly: > > > > > > acTree.dataProvider = xmlResult; > > > > > > > > > > > > Tracy > > > > > > > > > > > > ________________________________ > > > > > > From: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > ] > > On > > > Behalf Of malik_robinson > > > Sent: Tuesday, February 06, 2007 3:09 PM > > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > > > > Subject: [flexcoders] Re: Populate Tree with data from a query? > > > > > > > > > > > > Hi, > > > > > > That helps a bit, in my tree I am seeing the actual xml when I run > my > > > application in flex. I have CFC function returning a string, I tried > > > having return xml and same thing. > > > > > > ******************* > > > After I make my remote object call in my result handler I have this: > > > > > > public function result( data:Object ):void { > > > var event:ResultEvent = data as ResultEvent > > > model.treeData = event.result as XML; > > > } > > > > > > It seems I have to cast it as XML otherwise in my "model" I get a > > 'type' > > > error > > > > > > ************** > > > In my model which is a [Bindable] class I have: > > > > > > public var treeData:XML; > > > > > > ****************** > > > And in the view I have > > > > > > <mx:Tree id="acTree" > > > width="50%" > > > height="100%" > > > showRoot="false" > > > dataProvider="{model.treeData}" > > > change="treeChanged(event)" > > > /> > > > > > > Any help appreciated as I am getting the actual xml in the tree. How > > do > > > you get the label to work also? > > > > > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > <mailto:flexcoders%40yahoogroups.com> > > > , "jensen.axel" axel@ wrote: > > > > > > > > Hi Malik, > > > > > > > > I have never exactly populated a tree with straight query data, i > > > > usually convert it to xml first within the cfc that i'm calling, > and > > i > > > > return a string from that cfc... it took some playing with but i > > > > eventually got it... > > > > > > > > google the following: > > > > > > > > "using cfxml returning it to flex?" or something along those > > lines... > > > > that will teach you how to convert your query to xml... but the > > thing > > > > is, flex doesn't want the actual xml doc from coldfusion, it wants > > the > > > > valid string format... > > > > > > > > here is my example > > > > > > > > > > > > > > http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex- > <http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex > -> > > > \ > > > as-xml#more > > > > > > <http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex > <http://axel.cfwebtools.com/index.cfm/2007/2/6/Returning-a-query-to-flex > > > > > -as-xml#more> > > > > > > > > once you get it into flex, it will be declared as xml, and then in > > > > your mx:Tree your going to declare a showRoot="false" > > > > > > > > the blog might be a little hard to follow, but I hope it helps. > > > > > > > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > > <mailto:flexcoders%40yahoogroups.com> , "malik_robinson" > > > > Malik_Robinson@ wrote: > > > > > > > > > > > > > > > Hi, > > > > > > > > > > I want to display a list of companies and contacts associated > with > > > each > > > > > company in my app. I think a tree can do this, but I wanted to > ask > > > how > > > > > can I populate a tree from a query? I would like the folders to > be > > > the > > > > > companies and when you expand the folder you see a list of > > contacts > > > > > associated. > > > > > > > > > > I am using CF so in CF I have a query that does a group by so > I'd > > > like > > > > > to use that and populate the tree but I am unsure on how to do > > this. > > > I > > > > > understand the tree needs a data provider, but how do I handle > the > > > > > grouping? > > > > > > > > > > Thanks > > > > > > > > > > -M > > > > > > > > > > > > > > >