User Guide

Table Of Contents
Building tree controls with the cftree tag 635
To create and populate a tree control from a query:
1.
Create a ColdFusion page with the following content:
<cfquery name="engquery" datasource="cfdocexamples">
SELECT FirstName + ' ' + LastName AS FullName
FROM Employee
</cfquery>
<cfform name="form1" action="submit.cfm">
<cftree name="tree1"
required="Yes"
hscroll="No">
<cftreeitem value="FullName"
query="engquery"
queryasroot="Yes"
img="folder,document">
</cftree>
</cfform>
2.
Save the page as tree1.cfm and view it in your browser.
The following figure shows the output of this CFML page:
Reviewing the code
The following table describes the highlighted code and its function:
Code Description
<cftree name="tree1"
Creates a tree and names it tree1.
required="Yes"
Specifies that a user must select an item in the tree.
hscroll="No"
Does not allow horizontal scrolling.
<cftreeitem value="FullName"
query="engquery"
Creates an item in the tree and puts the results of the query named
engquery in it. Because this tag uses a query, it puts one item on
the tree per query entry.