|
ColdFusion 9.0 Resources |
cftreeitemSyntax<cftreeitem
value = "text"
bind = "bind expression"
display = "text"
expand = "yes|no"
href = "URL"
img = "filename"
imgopen = "filename"
parent = "parent name"
query = "queryname"
queryAsRoot = "yes|no"
target = "URL target">
OR
<cftreeitem
bind = "bind expression">
onBindError = "JavaScript function name"
Note: You can specify this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
See alsocfapplet, cfform, cfformgroup, cfformitem, cfgrid, cfinput, cfselect, cfslider, cftextarea, cftree; Building tree controls with the cftree tag and Using HTML trees in the Developing ColdFusion Applications AttributesNote: In XML format, ColdFusion passes all attributes
to the XML. The supplied XSLT skins do not handle or display XML
format trees, but do display applet and Flash format trees.
UsageFor this tag to work properly. the browser must be JavaScript-enabled. This tag must be a child of a cftree tag. The cftreeitem tag has three basic formats:
ExampleThe following example creates a simple tree by using a single cftreeitem tag and a query: <cfform action = "#cgi.script_name#">
<cftree name = "Employees" height = "400" width = "200">
<cftreeitem value="LastName, FirstName, Emp_ID" query="getEmployees"
queryAsRoot="False">
</cftree>
</cfform>
The following example creates a tree that shows the basic information about all employees in an organization, organized by department. The departments are expanded to show all employees. You click the + signs to display additional information. If you click the employee name, ColdFusion links back to the same page and displays the selected employee’s ID. <!--- Query the datasource to get employee information.--->
<!--- Group the output by Department.
(All fields are required in Group By clause.) --->
<cfquery name = "GetEmployees" dataSource = "cfdocexamples">
SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department
FROM Employees
GROUP BY Department, Emp_ID, FirstName, LastName, EMail, Phone
</cfquery>
<html>
<body>
<h3>cftreeitem Example</h3>
<!--- The following runs if the user clicked on a link in the tree.
A complete application would use the ID for additional processing. --->
<cfif isdefined("URL.user_ID")>
<cfoutput>
<!--- URL.cftreeitemkey is the selected tree item's value attribute. --->
You Requested information on #URL.cftreeitemKey#; User ID #URL.user_ID#
</cfoutput>
<br><br>
</cfif>
<!--- Display the tree. The cftree tag must be in a cfform. --->
<cfform>
<cftree name = "Employees" height = "400" width = "200"
font = "Arial Narrow" highlighthref="No" hscroll="No">
<!--- cfoutput tag with a group attribute loops over the departments. --->
<cfoutput group="Department" query = "GetEmployees">
<cftreeitem value="#Department#" parent="Employees" expand="yes">
<!--- This cfoutput tag loops over the records for the department.
The cfoutput tag does not need any attributes. --->
<cfoutput>
<!--- Create an item for each employee in the department.
Do not expand children. Each employee name links to this page,
and sends the employee ID in the query string.--->
<cftreeitem value = "#LastName#, #FirstName#"
display = "#LastName#, #FirstName#"
parent = "#Department#" expand="no"
href="#cgi.script_name#?user_id=#emp_id#">
<!--- Each Employee entry has ID and ContactInfo children. --->
<cftreeitem value = "#Emp_ID#" display = "Employee ID: #Emp_ID#"
parent = "#LastName#, #FirstName#">
<!--- Each node must be unique value, so use Emp_ID om value. --->
<cftreeitem value = "#Emp_ID#_ContactInfo"
display = "Contact Information"
parent = "#LastName#, #FirstName#" expand = "No">
<!--- ContactInfo has two children. --->
<cftreeitem value = "#Phone#" parent = "#Emp_ID#_ContactInfo">
<cftreeitem value = "#Email#" parent = "#Emp_ID#_ContactInfo">
</cfoutput>
</cfoutput>
</cftree>
</cfform>
|