Adobe COLDFUSION 9 Manual page 742

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Code
<cfgrid name="employee_grid"
height=425
width=300
vspace=10
selectmode="edit"
query="empdata"
insert="Yes"
delete="Yes">
<cfgridcolumn name="Emp_ID"
header="Emp ID"
width=50
headeralign="center"
headerbold="Yes"
select="No">
<cfgridcolumn name="LastName"
header="Last Name"
width=100
headeralign="center"
headerbold="Yes">
<cfgridcolumn name="Dept_ID"
header="Dept"
width=35
headeralign="center"
headerbold="Yes">
Updating the database with the cfgridupdate tag
The
tag provides a simple mechanism for updating the database, including inserting and deleting
cfgridupdate
records. It can add, update, and delete records simultaneously. It is convenient because it automatically handles
collecting the
changes from the various form variables, and generates appropriate SQL statements to update
cfgrid
your data source.
In most cases, use the
cfgridupdate
SQL control that the
cfquery
• 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.
Update the data source with the cfgridupdate tag
Create a ColdFusion page with the following contents:
1
Description
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.
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.
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.
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.
tag to update your database. However, this tag does not provide the complete
tag provides. In particular, the
Last updated 8/5/2010
tag has the following characteristics:
cfgridupdate
737

Advertisement

Table of Contents
loading

Table of Contents