The cfgrid
tag to creates a cfform
grid control. A grid control resembles a spreadsheet table and can contain data populated from a cfquery
or from other sources of data. As with other cfform
tags, cfgrid
offers a wide range of data formatting options as well as the option of validating user selections with a JavaScript validation script.
You can also do the following with cfgrid
:
Users can sort the grid entries in ascending order by double-clicking any column header. Double-clicking again sorts the grid in descending order. You can also add sort buttons to the grid control.
When users select grid data and submit the form, ColdFusion passes the selection information as form variables to the application page specified in the cfform
action
attribute.
Just as the cftree
tag uses cftreeitem
, cfgrid
uses the cfgridcolumn
tag. You can define a wide range of row and column formatting options, as well as a column name, data type, selection options, and so on. You use the cfgridcolumn
tag to define individual columns in the grid or associate a query column with a grid column.
The cfgrid
tag provides many attributes that control grid behavior and appearance. This document can only cover the most important of these. For detailed information on these attributes, see the CFML Reference.
grid1.cfm
in ColdFusion Studio.
<cfquery name="empdata" datasource="CompanyInfo"> SELECT * FROM Employee </cfquery> <cfform name="Form1" action="submit.cfm" method="Post"> <cfgrid name="employee_grid" query="empdata" selectmode="single"> <cfgridcolumn name="Emp_ID"> <cfgridcolumn name="LastName"> <cfgridcolumn name="Dept_ID"> </cfgrid> <br><input type="Submit" value="Submit"> </cfform>
Note Use the |
The following table describes the highlight code and its function:
Note If you specify a |