cftreeitem

Description

Populates a tree control, created with cftree, with elements. You can use the img values supplied with ColdFusion or reference your own icons.

Category

Forms tags

Syntax


<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"> 

See also

cfapplet, cfform, cfgrid, cfgridcolumn, cfgridrow, cfgridupdate, cfinput, cfselect, cfslider, cftextinput, cftree

Attributes

Attribute
Description
value
Required. Value passed when the cfform is submitted. When populating a cftree with data from a cfquery, columns are specified in a comma-separated list:

value = "dept_id,emp_id" 

display
Optional. The label for the tree item. Default is value. When populating a cftree with data from a cfquery, display names are specified in a comma-separated list:

display = "dept_name,emp_name" 

parent
Optional. Value for tree item parent.
img
Optional. Image name or filename for the tree item. When populating a cftree with data from a cfquery, images or filenames for each level of the tree are specified in a comma-separated list.
The default image name is "Folder. " The following images are supplied and can be specified using the image name (no file extension):
  • cd
  • computer
  • document
  • element
  • folder
  • floppy
  • fixed
  • remote
Use commas to separate image names corresponding to tree level, for example:

img = "folder,document" 

img = ",document" 

To specify a custom image, specify the path and file extension:

img = "../images/page1.gif" 

imgopen
Optional. Icon displayed with open tree item. You can specify the icon filename using a relative path. As with img, you can use an image supplied with ColdFusion.
href
Optional. URL to associate with the tree item or a query column for a tree that is populated from a query. If href is a query column, the href value is the value populated by the query. If href is not recognized as a query column, it is assumed that the href text is an actual HTML href.
When populating a cftree with data from a cfquery, HREFs can be specified in a comma-separated list

href = "http://dept_server,http://emp_server" 

target
Optional. Target attribute for href URL. When populating a cftree with data from a cfquery, targets are specified in a comma-separated list:

target = "FRAME_BODY,_blank" 

query
Optional. Query name used to generate data for the treeitem.
queryAsRoot
Optional. Yes or No. Defines specified query as the root level. As in Example 1, this option avoids having to create an additional parent cftreeitem.
If you specify a text string other than "Yes" or "No", the tag uses the text as the root text.
expand
Optional. Yes or No. Yes expands tree to show tree item children. No keeps tree item collapsed. Default is Yes

Usage


Note

The cftreeitem tag incorporates a Java applet. For cftree to work properly, a browser must be Java-enabled.


Example

<!--- 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>

...



Banner.Novgorod.Ru