User Guide

Creating an Updateable Grid 155
Note
If you specify a
cfgrid tag with a query attribute defined and no corresponding
cfgriditem attributes the grid contains all the columns in the query.
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 use an updateable grid in either of two ways to make changes to your
ColdFusion data sources:
Create a page to which you pass the
cfgrid form variables. In that page perform
cfquery operations to update data source records base on the form values
returned by
cfgrid.
Pass grid edits to a page that includes the cfgridupdate tag, which automatically
extracts the form variable values and passes that data directly to the data source.
Using cfquery gives you complete control over interactions with your data source.
The
cfgridupdate tag provides a much simpler interface for operations that do not
require the same level of control.
Navigating and entering data in a grid
Navigating and using the cfgrid control is fairly straightforward, but here are a few
tips:
To sort grid rows so that a column is in ascending order by double-clicking the
column header. Double-clicking again sorts the rows in descending order.
To rearrange the columns, click any column heading and drag the column to a
new position.
When you click a cell (or row or column) that you cannot edit, its background
color changes. The default color is a salmon pink.
When you click a cell that you can edit, it is surrounded by a yellow box.
To edit a cell, Double-click it. You must press Return when you finish entering
the data.
To delete a row, click any cell in the row and click the Delete button.
To insert a row, click the Insert button. An empty row appears at the bottom of
the grid. To enter a value in each cell, double-click the cell, enter the value, and
click Return.