CFCOL

Defines table column header, width, alignment, and text. Only used inside a CFTABLE.

Syntax

<CFCOL HEADER="text"
    WIDTH="number"
    ALIGN="position"
    TEXT="text">

HEADER

The text to use for the column's header.

WIDTH

The width of the column in characters (the default is 20). If the length of the data displayed exceeds the width value, the data is truncated to fit.

ALIGN

Column alignment, Left, Right, or Center.

TEXT

Double-quote delimited text that determines what displays in the column. The rules for the text attribute are identical to the rules for CFOUTPUT sections, meaning that it can consist of a combination of literal text, HTML tags, and query record set field references. This means you can embed hyperlinks, image references, and even input controls within table columns.

Example

<!--- This example shows the use of CFCOL and CFTABLE
to align information returned from a query --->

<!--- this query selects employee information from the
cfsnippets data source --->
<CFQUERY NAME="GetEmployees" DATASOURCE="cfsnippets">
SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department
FROM   Employees
</CFQUERY>

<HTML>
<HEAD>
<TITLE>
CFCOL Example
</TITLE>
</HEAD>

<BODY>
<H3>CFCOL Example</H3>

<!--- Note the use of the HTMLTABLE attribute to display the
CFTABLE as an HTML table, rather simply as PRE formatted information --->
<CFTABLE QUERY="GetEmployees" STARTROW="1" COLSPACING="3" HTMLTABLE>
<!--- each CFCOL tag sets the width of a column in the table,
as well as specifying the header information and the text/CFML
with which to fill the cell --->
    <CFCOL HEADER = "<B>ID</B>"
        ALIGN = "Left"
        WIDTH = 2
        TEXT  = "#Emp_ID#">
    <CFCOL HEADER = "<B>Name/Email</B>"    
        ALIGN = "Left"
        WIDTH = 15
        TEXT  = "<a href='mailto:#Email#'>#FirstName# #LastName#</A>">
    <CFCOL HEADER = "<B>Phone Number</B>"
        ALIGN = "Center"
        WIDTH = 15
        TEXT  = "#Phone#">
</CFTABLE>

</BODY>
</HTML>