User Guide

Table Of Contents
636 Chapter 27: Building Dynamic Forms with cfform Tags
Grouping output from a query
In a query that you display using a
cftree control, you might want to organize your employees
by 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.
Create a ColdFusion page named tree2.cfm with the following content:
<!--- CFQUERY with an ORDER BY clause. --->
<cfquery name="deptquery" datasource="cfdocexamples">
SELECT Dept_ID, FirstName + ' ' + LastName
AS FullName
FROM Employee
ORDER BY Dept_ID
</cfquery>
<!--- Build the tree control. --->
<cfform name="form1" action="submit.cfm">
<cftree name="tree1"
hscroll="No"
border="Yes"
height="350"
required="Yes"
>
<cftreeitem value="Dept_ID, FullName"
query="deptquery"
queryasroot="Dept_ID"
img="computer,folder,document"
imgopen="computer,folder"
expand="yes">
</cftree>
<br>
<br><input type="Submit" value="Submit">
</cfform>
queryasroot="Yes"
Specifies the query name as the root level of the tree control.
img="folder,document"
Uses the folder and document images that ship with ColdFusion in
the tree structure.
When populating a
cftree tag with data from a cfquery tag, you
can specify images or filenames for each level of the tree as a
comma-separated list.
Code Description