User Guide

Table Of Contents
Creating data grids with the cfgrid tag 651
Reviewing the code
The following table describes the code and its function:
Updating the database with the cfgridupdate tag
The
cfgridupdate tag provides a simple mechanism for updating the database, including
inserting and deleting records. It can add, update, and delete records simultaneously. It is
convenient because it automatically handles collecting the
cfgrid changes from the various form
variables, and generates appropriate SQL statements to update your data source.
In most cases, use the
cfgridupdate tag to update your database. However, this tag does not
provide the complete SQL control that the
cfquery tag provides. In particular, the
cfgridupdate tag has the following characteristics:
You can update only a single table.
Rows are deleted first, then rows are inserted, then any changes are made to existing rows. You
cannot modify the order of changes.
Updating stops when an error occurs. It is possible that some database changes are made, but
the tag does not provide any information on them.
Code Description
<cfgrid name="employee_grid"
height=425
width=300
vspace=10
selectmode="edit"
query="empdata"
insert="Yes"
delete="Yes">
Populates a cfgrid control with data from the empdata query.
Selecting a grid cell enables you to edit it. You can insert and
delete rows. The grid is 425 X 300 pixels and has 10 pixels of
space above and below it.
<cfgridcolumn name="Emp_ID"
header="Emp ID"
width=50
headeralign="center"
headerbold="Yes"
select="No">
Creates a 50-pixel wide column for the data in the Emp_ID
column of the data source. Centers a header named Emp ID
and makes it bold.
Does not allow users to select fields in this column for editing.
Since this field is the table’s primary key, users should not be
able to change it for existing records, and the DBMS should
generate this field as an autoincrement value.
<cfgridcolumn name="LastName"
header="Last Name"
width=100
headeralign="center"
headerbold="Yes">
Creates a 100-pixel wide column for the data in the LastName
column of the data source. Centers a header named Last Name
and makes it bold.
<cfgridcolumn name="Dept_ID"
header="Dept"
width=35
headeralign="center"
headerbold="Yes">
</cfgrid>
Creates a 35-pixel wide column for the data in the Dept_ID
column of the data source. Centers a header named Dept and
makes it bold.