Populates a tree control, created with cftree
, with elements. You can use the img
values supplied with ColdFusion or reference your own icons.
<cftreeitem value = "text" display = "text" parent = "parent_name" img = "filename" imgopen = "filename" href = "URL" target = "URL_target" query = "queryname" queryAsRoot = "Yes" or "No" expand = "Yes" or "No">
cfapplet,
cfform,
cfgrid,
cfgridcolumn,
cfgridrow,
cfgridupdate,
cfinput,
cfselect,
cfslider,
cftextinput,
cftree
Note The |
<!--- This example shows the use of cftreeitem in a cfform.
The query takes a list of employees, and uses cftree and cfselect
to display the results of the query. In addition, cfgrid is used
to show an alternate means of displaying the same data --->
<!--- set a default for the employeeNames variable --->
<cfparam name = "employeeNames" default = "">
<!--- if an employee name has been passed from the form,
set employeeNames variable to this value ---Auto>
<cfif IsDefined("form.employeeNames")>
<cfset employeeNames = form.employeeNames>
</cfif>
<!--- query the datasource to find the employee information--->
<cfquery name = "GetEmployees" dataSource = "cfsnippets">
SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department
FROM Employees where lastname
<cfif #employeeNames# is not ""> = '
#employeeNames#'</cfif>
</cfquery>
<html>
<head>
<title>
cftree Example
</title>
</head>
<body>
<H3>cftreeitem Example</H3>
<!--- Use cfform when using other cfinput tools --->
<cfform action = "cftreeitem.cfm" method = "POST" enableCAB = "Yes">
<!--- Use cfselect to present the contents of the query by column --->
<H3>cfselect Presentation of Data</H3>
<H4>Click on an employee's last name and hit "see information for
this employee" to see expanded information.</H4>
<cfselect name = "EmployeeNames" message = "Select an Employee Name"
size = "#getEmployees.recordcount#" query = "GetEmployees"
value = "LastName" required = "No">
<option value = "">Select All
</cfselect>
<input type = "Submit" name = ""
value = "see information for this employee">
<!--- showing the use of cftree --->
<!--- Use cftree for an expanded presentation of the data --->
<!--- Loop through the query to create each branch of the cftree --->
<H3>cftree Presentation of Data</H3>
<H4>Click on the folders to "drill down" and reveal information.</H4>
<P>cftreeitem is used to create the "branches" of the tree.
<P>
<cftree name = "SeeEmployees" height = "150" width = "240"
font = "Arial Narrow" bold = "No"
italic = "No" border = "Yes"
hScroll = "Yes" vScroll = "Yes"
required = "No" completePath = "No"
appendKey = "Yes" highlightHref = "Yes">
<cfloop query = "GetEmployees">
<cftreeitem value = "#Emp_ID#" parent = "SeeEmployees" expand = "No">
<cftreeitem value = "#LastName#" display = "Name"
parent = "#Emp_ID#" queryAsRoot = "No"
expand = "No">
<cftreeitem value = "#LastName#, #FirstName#"
parent = "#LastName#" expand = "No"
queryAsRoot = "No">
<cftreeitem value = "#Department#" display = "Department"
parent = "#Emp_ID#" queryAsRoot = "No"
expand = "No">
<cftreeitem value = "#Department#" parent = "#Department#"
expand = "No" queryAsRoot = "No">
<cftreeitem value = "#Phone#" display = "Phone"
parent = "#Emp_ID#" queryAsRoot = "No"
expand = "No">
<cftreeitem value = "#Phone#" parent = "#Phone#"
expand = "No" queryAsRoot = "No">
<cftreeitem value = "#Email#" display = "Email"
parent = "#Emp_ID#" queryAsRoot = "No"
expand = "No">
<cftreeitem value = "#Email#" parent = "#Email#"
expand = "No" queryAsRoot = "No">
</cfloop>
</cftree>
...