Chapter 10: Building Dynamic Forms
Code Review
Code
<CFGRID NAME="employee_grid"
QUERY="empdata"
SELECTMODE="single">
<CFGRIDCOLUMN NAME="Employee_ID">
<CFGRIDCOLUMN NAME="LastName">
<CFGRIDCOLUMN NAME="Department_ID">
Note
Creating an Updateable Grid
You can build grids to allow users to edit data within them. Users can edit individual
cell data, as well as insert, update, or delete rows. To enable grid editing, you specify
SELECTMODE="EDIT" in the CFGRID tag and enable the INSERT or DELETE
attributes in CFGRID.
You can then use either of two ways to use an updateable grid to make changes to your
ColdFusion data sources.
Create a page to which you pass the CFGRID form variables and in that page
perform CFQUERY operations to update data source records.
Pass grid edits to a page that includes the CFGRIDUPDATE tag, which passes
data directly to the data source.
Although using CFQUERY gives you complete control over interactions with your data
source, CFGRIDUPDATE provides a much simpler interface for operations that do not
require the same level of control.
If you specify a CFGRID tag with a QUERY attribute defined and no
corresponding CFGRIDITEM attributes the default grid that is created
contains all the columns in the query.
Description
Create a grid named "employee_grid"
and popluate it with the results of the
query "empdata"
Allow the user to select only one cell.
Put the contents of the Employee_ID
column in the query results in the first
column of the grid
Put the contents of the LastName
column in the query results in the
second column of the grid
Put the contents of the
Department_ID column in the query
results in the third column of the grid
137
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?