# CFGRIDCOLUMN

Used with CFGRID in a CFFORM, you use CFGRIDCOLUMN to specify individual column data in a CFGRID control. Font and alignment attributes used in CFGRIDCOLUMN override any global font or alignment settings defined in CFGRID.

### Syntax

    <CFGRIDCOLUMN NAME="column_name"
        HEADER="header"
        WIDTH="column_width"
        FONT="column_font"
        FONTSIZE="size"
        ITALIC="Yes/No"
        BOLD="Yes/No"
        HREF="URL"
        HREFKEY="column_name"
        TARGET="URL_target"
        SELECT="Yes/No"
        DISPLAY="Yes/No"
        TYPE="type"
        HEADERFONT"font_name"
        HEADERFONTSIZE="size"
        HEADERITALIC="Yes/No"
        HEADERBOLD="Yes/No"
        DATAALIGN="position"
        HEADERALIGN="position"
        NUMBERFORMAT="format">

#### NAME

Required. A name for the grid column element. If the grid uses a query, the column name must specify the name of a query column.

#### HEADER

Optional. Text for the column header. The value of HEADER is used only when the CFGRID COLHEADERS attribute is Yes (or omitted, since it defaults to Yes).

#### WIDTH

Optional. The width of the column in pixels. By default the column is sized based on the longest column value.

#### FONT

Optional. Font name to use for data in the column. Defaults to browser-specified font.

#### FONTSIZE

Optional. Font size for text in the column. Defaults to browser-specified font size.

#### ITALIC

Optional. Yes or No. Yes presents text in the column in italic. Default is No.

#### BOLD

Optional. Yes or No. Yes presents text in the column in boldface. Default is No.

#### HREF

Optional. URL to associate with the grid item. You can specify a URL that is relative to the current page:

    ../mypage.cfm

Or an absolute URL:

    http://myserver.com/mydir/mypage.cfm.

#### HREFKEY

Optional. The name of a valid query column when the grid uses a query. The column specified becomes the Key no matter what the select mode is for the grid.

#### TARGET

Optional. The name of the frame in which to open the link specified in HREF.

#### SELECT

Optional. Yes or No. Yes allows end users to select a column in a grid control. When No, the column cannot be edited, even if the CFGRID INSERT or DELETE attributes are enabled. The value of the SELECT attribute is ignored if the CFGRID SELECTMODE attribute is set to Row or Browse.

#### DISPLAY

Optional. Yes or No. Use to hide columns. Default is Yes to display the column.

#### TYPE

Optional. Enter Image, Numeric, or String_NoCase. When TYPE="Image", the grid attempts to display an image corresponding to the value in the column, which can be a built in ColdFusion image name, or an image of your choice in the `cfide\classes` directory or a subdirectory, referenced with a relative URL. Built-in image names are as follows:

- cd
- computer
- document
- element
- folder
- floppy
- fixed
- remote

If an image is larger than the column cell where it is being placed, the images is clipped to fit the cell.

When TYPE="Numeric", data in the grid can be sorted by the end user as numeric data rather than as simple character text.

When TYPE="String_NoCase", data in the grid can be sorted by the end user as case insensitive text data like an Excel spreadsheet rather than as case sensitive character text.

#### HEADERFONT

Optional. Font to use for the column header. Defaults to browser-specified font.

#### HEADERFONTSIZE

Optional. Font size to use for the column header in pixels. Defaults to browser-specified font size.

#### HEADERITALIC

Optional. Yes or No. Yes presents column header text in italic. Default is No.

#### HEADERBOLD

Optional. Yes or No. Yes presents header text in boldface. Default is No.

#### DATAALIGN

Optional. Alignment for column data. Valid entries are: Left, Center, or Right. Default is Left.

#### HEADERALIGN

Optional. Alignment for the column header text. Valid entries are: Left, Center, or Right. Default is Left.

#### NUMBERFORMAT

Optional. The format for displaying numeric data in the grid.

### NUMBERFORMAT mask characters

Mask characters you can use in the NUMBERFORMAT attribute correspond with those used in the NumberFormat CFML function. For more information about the NumberFormat function, see Chapter 2, "ColdFusion Functions".

NumberFormat Mask Characters
Character | Meaning
--- | ---
_ (underscore) | Optional digit placeholder.
9 | Optional digit placeholder. Same as _, but shows decimal places more clearly.
. | Specifies the location of a mandatory decimal point.
0 | Located to the left or right of a mandatory decimal point, to force padding with zeros.
( ) | Places parentheses around the mask if the number is less than 0.
+ | Places + in front of positive numbers, - (minus sign) in front of negative numbers.
- | Place " " (space) in front of positive, - (minus sign) in front of negative numbers.
, | Separates thousands with commas.
L,C | Specifies left-justify or center-justify a number within the width of the mask column. L or C must appear as the first character of the mask. By default, numbers are right-justified.
$ | Places a dollar sign in front of the formatted number. $ must appear as the first character of the mask.
^ | Separates left from right formatting.

### Example

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