CFTree populated with Flash remoting and XML

As part of these series "How to populate a cf[…] with Remoting", I wanted to show how to bring data into a cftree. This is the easiest way, but it has some limitations: your xml data has to have a label attribute and the tree is first closed when it loads. If you want to get around those, you will have to do more work with the data returned from the server (I may do it if I have time :)).


As part of these series “How to populate a cf[…] with Remoting”, I wanted to show how to bring data into a cftree. This is the easiest way, but it has some limitations: your xml data has to have a label attribute and the tree is first closed when it loads. If you want to get around those, you will have to do more work with the data returned from the server (I may do it if I have time :)).

The function that handles the response it’s the same as in the cfgrid example:

responseHandler.onResult = function( results: Object ):Void { //when results are back, populate the cftree categories.dataProvider = results; }

The main difference is in the cfc function. In this case, it will return an xml object. Each node has a label attribute and any other attribute we want. Important: You must remove all whitespace from the xml string.

the rest of the nodes...

And the form:

Note that to access other attributes in the xml node, you must reference them as:

myTree.selectedNode.getProperty('myAtribute');

A live example
Download the source