<cfgridcolumn name = "column_name" header = "header" width = "column_width" font = "column_font" fontSize = "size" italic = "Yes" or "No" bold = "Yes" or "No" textColor = "Web color" or "expression" bgColor = "Web color" or "expression" href = "URL" hrefKey = "column_name" target = "URL_target" select = "Yes" or "No" display = "Yes" or "No" type = "type" headerFont = "font_name" headerFontSize = "size" headerItalic = "Yes" or "No" headerBold = "Yes" or "No" colHeaderTextColor = "Web color" dataAlign = "position" headerAlign = "position" numberFormat = "format" values = "Comma separated strings and/or numeric range" valuesDisplay = "Comma separated strings and/or numeric range" valuesDelimiter = "delimiter character">
Used with cfgrid
in a cfform
, you use cfgridcolumn
to specify column data in a cfgrid
control. Font and alignment attributes used in cfgridcolumn
override any global font or alignment settings defined in cfgrid
.
cfapplet,
cfform,
cfinput,
cfselect,
cfslider,
cftextinput,
cftree,
cfgrid,
cfgridrow,
cfgridupdate
The textColor
and bgColor
attributes accept a color value literal or an expression that lets you select a text color based on the evaluation of a simple boolean expression. The basic syntax for this expression is as follows:
(CX operator string ? true_condition : false_condition)
CX
The column containing the value you want to test. Use CX
for the current column and C
n, where n is the column you want to evaluate; for example, C2
EQ
(equal), GT
(greater than), LT
(less than)(C2 EQ Johnson ? blue : green)
, or a numeric value: (C2 LT 0 ? red : black)
textColor
if condition evaluates to "true"textColor
if condition evaluates to "false"The comparisons in the expression are interpreted as numeric if the string supplied in the expression can be interpreted as a number. Otherwise the comparison is a standard string comparison.
This code fragment shows an expression that changes the text color for the grid element to blue if the grid element contains the string "Peter," and black otherwise.
<cfgridcolumn name = "FirstName" textColor = "(CX EQ Peter ?
blue : black)">
The next example displays the text in red if the value in column 1 is greater than four and black otherwise:
<cfgridcolumn name = "FirstName" textColor = "(C1 GT 4 ? blue : black)">
Mask characters you can use in the numberFormat
attribute correspond to those used in the NumberFormat CFML function.
<!--- This example shows the cfgridcolumn tag in action ---> ... <cfgrid name = "FirstGrid" width = "450" query = "GetCourses" insert = "Yes" delete = "Yes" sort = "Yes" font = "Tahoma" bold = "No" italic = "No" appendKey = "No" highlightHref = "No" gridDataAlign = "LEFT" gridLines = "Yes" rowHeaders = "Yes" rowHeaderAlign = "LEFT" rowHeaderItalic = "No" rowHeaderBold = "No" colHeaders = "Yes" colHeaderAlign = "LEFT" colHeaderItalic = "No" colHeaderBold = "No" selectColor = "Red" selectMode = "EDIT" pictureBar = "No" insertButton = "To insert" deleteButton = "To delete" sortAscendingButton = "Sort ASC" sortDescendingButton = "Sort DESC"> <cfgridcolumn name = "Course_ID" dataAlign = "LEFT" bold = "No" italic = "No" select = "No" display = "No" headerBold = "No" headerItalic = "No"> <cfgridcolumn name = "Dept_ID" header = "Department" headerAlign = "LEFT" dataAlign = "LEFT" bold = "Yes" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "Yes"> <cfgridcolumn name = "CorNumber" header = "Course ##" headerAlign = "LEFT" dataAlign = "LEFT" bold = "No" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "No"> <cfgridcolumn name = "CorName" header = "Name" headerAlign = "LEFT" dataAlign = "LEFT" font = "Times" bold = "No" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "No"> <cfgridcolumn name = "CorLevel" header = "Level" headerAlign = "LEFT" dataAlign = "LEFT" bold = "No" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "No"> ...