User Guide

Table Of Contents
Creating data grids with the cfgrid tag 649
The value of the array index increments for each row that is added, deleted, or changed, and does
not indicate a grid row number. All rows for a particular change have the same index in all arrays.
Unchanged rows do not have entries in the arrays.
If the user makes a change to a single cell in col2, the following array elements contain the edit
operation, the edited cell value, and the original cell value:
Form.mygrid.RowStatus.Action[1]
Form.mygrid.col2[1]
Form.mygrid.original.col2[1]
If the user changes the values of the cells in col1 and col3 in one row and the cell in col2 in
another row, the information about the original and changed values is in the following array
entries:
Form.mygrid.RowStatus.Action[1]
Form.mygrid.col1[1]
Form.mygrid.original.col1[1]
Form.mygrid.col3[1]
Form.mygrid.original.col3[1]
Form.mygrid.RowStatus.Action[2]
Form.mygrid.col2[2]
Form.mygrid.original.col2[2]
The remaining cells in the arrays (for example, Form.mygrid.col2[1] and
Form.mygrid.original.col2[1]) have the original, unchanged values.
Example: editing data in a grid
The following example creates an editable grid. For code brevity, the example handles only three
of the fields in the Employee table. A more realistic example would include, at a minimum, all
seven table fields. It might also hide the contents of the Emp_ID column or display the
Department name (from the Departmt table), instead of the Department ID.
To create the editable grid:
1.
Create a ColdFusion page with the following content:
<cfquery name="empdata" datasource="cfdocexamples">
SELECT * FROM Employee
</cfquery>
<cfform name="GridForm"
action="handle_grid.cfm">
<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"