PDA

View Full Version : Tree Trouble


ackerchez
03-12-2009, 10:57 AM
Hi Everyone, I need some help with a tree control.

Here is the issue:
I have a serverside httpservice call and return with php, php returns an xmllist that looks like this:

<root>
<sectioncode>
1
<labtitle>
Biological Materials
</labtitle>
</sectioncode>
<sectioncode>
2
<labtitle>
Chemical Materials
</labtitle>
</sectioncode>
</root>

I would like to bind this result to a tree control so that it displays nicely for all to see but something is going wrong. When I set the dataprovider of the tree to "get_sections.lastResult.sectioncode," the tree forms but the first folder (which I would like to just show the "sectioncode" value) shows:
"<sectioncode>
1
<labtitle>
Biological Materials
</labtitle>
</sectioncode>"

as the folder name, then it shows "1" (which is the value that I want on the folder) as an item within the folder. Beneath that, I am getting the title as a folder within the first folder with the xml formatting and then another object with the title in there (this sounds complicated if you can't see it). I am not sure what I am doing wrong becasue the xml seems to be coming back from php correctly. The result I am looking for is as follows:

1
Biological Materials

2
Chemical Materials

I would like the titles to be a child of the "sectioncode" value, so that you would have a folder with the sectioncode (1 and 2) and when you click on the folder, you would see the titles within the folder. Can anyone help here??

Thanks!

ackerchez
03-12-2009, 09:11 PM
I figured it out myself. Here is what I did.

My php code is outputing with label properties as follows:
$xml.= "<sectioncode label=\"$sectioncode\">";
$xml.= "<labtitle label=\"$title\">";
$xml.="</labtitle>";
$xml.="</sectioncode>";

Once I did that (and it took a while to get the correct formatting) I set the dataprovider of the tree as "{get_sections.lastResult }" and made the labelfield "labelField="@label."" with all that the tree is displaying correctly and not making subnodes for everything. YAY!!