User Guide

130 Developing Web Applications with ColdFusion
4 QUERY="engquery"
4 QUERYASROOT="yes"
4 IMG="folder,document">
4 </CFTREE>
</CFFORM>
3. Save the page and view it in your browser.
Code Review
Grouping output from a query
In a similar query, you may want to organize your employees by the department. In
this case, you separate column names with commas in the CFTREEITEM VALUE
attribute
To organize the tree based on ordered results of a query:
1. Open a new file named tree2.cfm in Studio.
2. Modify the page so that it appears as follows:
<!--- CFQUERY with an ORDER BY clause --->
<CFQUERY NAME="deptquery" DATASOURCE="CompanyInfo">
SELECT Department_ID, FirstName + ’ ’ + LastName
AS FullName
FROM EMPLOYEES
ORDER BY Department_ID
</CFQUERY>
Code Description
<CFTREE NAME="tree1"
Create a tree and name it tree1.
REQUIRED="yes"
Specify that a user must select
an item in the tree.
HSCROLL="no"
Don’t allow horizontal scrolling.
VSCROLL="yes">
Allow vertical scrolling.
<CFTREEITEM VALUE=FullName
QUERY="engquery"
Create an item in the tree and
put the results of the query
named engquery in it.
QUERYASROOT="yes"
Specify the query name as the
root level of the tree control.
IMG="folder,document"
Use the images "folder" and
"document" that ship with
ColdFusion in the tree structure.