150
Chapter 9 Building Dynamic Forms
Structuring Tree Controls
Tree controls built with
cftree
can be very complex. Knowing how to specify the
relationship between multiple
cftreeitem
entries will help you handle even the
most complex of
cftree
constructs.
Example: one-level tree control
This example consists of a single root and a number of individual items:
<cfquery name="deptquery" datasource="CompanyInfo">
SELECT Dept_ID, Fir ’ ’ + LastName
AS FullName
FROM Employee
ORDER BY Dept_ID
</cfquery>
<cfform name="form1" action="submit.cfm">
<cftree name="tree1">
<cftreeitem value="FullName"
query="deptquery"
queryasroot="Department">
</cftree>
<br>
<input type="submit" value="Submit">
</cfform>
Example: multilevel tree control
When populating a
cftree
, you manipulate the structure of the tree by specifying a
cftreeitem
parent. In this example, every cf
treeitem
, except the top level, specifies
a parent. The
parent
attribute allows your
cftree
to show the relationships between
elements in the tree control. (This example populates the tree directly, not with a
query.)
<cfform name="form2" action="cfform_submit.cfm"
method="Post">
<cftree name="tree1" hscroll="No" vscroll="No"
border="No">
<cftreeitem value="Divisions">
<cftreeitem value="Development"
parent="Divisions" img="folder">
<cftreeitem value="Product One"
parent="Development">
<cftreeitem value="Product Two"
parent="Development">
<cftreeitem value="GUI"
parent="Product Two" img="document">
<cftreeitem value="Kernel"
parent="Product Two" img="document">
<cftreeitem value="Product Three"
parent="Development">
<cftreeitem value="QA"
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...