
Building Tree Controls with cftree
149
Reviewing the code
The following table describes the highlight code and its function:
Note that the
cftreeitem
comma-separated
img
and the
value
attributes both
correspond to the tree level structure. If you leave out the
img
attribute, ColdFusion
uses the folder image for all levels in the tree except the individual items, which have
bullets.
cftree form variables
The
cftree
tag allows you to force a user to select an item from the tree control by
setting the
required
attribute to Yes. With or without the
required
attribute,
ColdFusion passes two form variables to the application page specified in the
cftree
action
attribute:
•
Form.treename.node
Returns the node of the user selection.
•
Form.treename.path
Returns the complete path of the user selection, in the
form: [root]\node1\node2\node_n\value
To return the root part of the path, set the
completepath
attribute of
cftree
to Yes;
otherwise, the path value starts with the first node. If you specify a root name in
queryastroot
, that value gets returned as the root.
In the previous example, if the user selects the name "John Allen" in the tree, the
following form variables are returned by ColdFusion:
Form.tree1.node = John Allen
Form.tree1.path = Dept_ID\3\John Allen
You can specify the character used to delimit each element of the path form variable
in the
cftree
delimiter
attribute. The default is a backslash.
Input validation
Although, the
cftree
does not include a
validate
attribute, you can use the
required
attribute to force a user to select an item from the tree control. In addition,
you can use the
onvalidate
attribute to specify the JavaScript code to perform
validation.
Code
Description
ORDER BY Dept_ID
Order the query results by department.
<cftreeitem
value="Dept_ID,
FullName"
Populate the tree with the Department ID, and under
each department, the Full Name for each employee
in the department.
queryasroot="Dept_ID"
Label the root "Dept_ID".
img="cd,folder">
Use the ColdFusion-supplied CD image for the root
level and Folder image for the department IDs. The
names are preceded by a bullet.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...