定义表格字段标题, 宽度, 对齐方式, 及文字. 只适用在cftable内.
<cfcol
header = "column_header_text"
width = "number_indicating_width_of_column"
align = "Left" or "Right" or "Center"
text = "column_text">
| 属性 |
必须/可选 |
默认 |
描述 |
|---|---|---|---|
header |
必须 |
|
使用这个属性,您必须使用cftable colHeaders属性. |
| width |
可选 | 20 | 宽度,以字符数计算(默认值为20). 若显示的资料长度超过宽度值, 资料后面会被截掉.避免这, 使用一个HTML 标记;如果周围的cftable 标记包括htmltable 属性, 宽度指定为百分比并且不会删除文本; 否则, 宽度必须指定字符的数量. |
| align | 可选 | Left | 选择属性. 字段对齐方式(默认left), 靠左, 靠右, 或居中. |
| text | 必须 | 在字段内显示的双引号分隔的文字. 这个属性的设定规则与cfoutput相同, 可以由文字, HTML tags,及查询记录的组成. 在字段内资料可以是超级链接, 图像参考, 及输入接口控制组件 |
至少要有一个cfcol 标记必需在cftable 标记之内。您必须把cfcol 和cftable 标记放在一个页面。您能创建在cftable 标记之内的唯一的标记是cfcol 标记。否则您无法创建cftable 标记。
显示cfcol 标记文本, 您必须指定cfcol 标记和cftable colHeader 属性。如果您指定或者没有其它属性, 标记将不显示。并且不会报错。
<cfquery name = "GetEmployees" dataSource = "cfsnippets">
SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department
FROM Employees
</cfquery>
<html>
<body>
<h3>cfcol Example</h3>
<cftable
query = "GetEmployees"
startRow = "1" colSpacing = "3"
HTMLTable colheaders>
<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>