User Guide
Creating an Updateable Grid 157
The value of change_index increments for each row that changes, and does not
indicate the specific row number. When the user updates data or inserts or deletes
rows, the action page gets one array for each changed column, plus the
RowStatsus.Action array. The action page does not get arrays for unchanged
columns.
If the user makes a change to a single cell in col2, you can access the edit operation,
the original cell value, and the edited cell value in the following arrays:
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]><BR>
Form.mygrid.col1[1]><BR>
Form.mygrid.original.col1[1]>
Form.mygrid.col3[1]><BR>
Form.mygrid.original.col3[1]>
Form.mygrid.RowStatus.Action[2]><BR>
Form.mygrid.col2[2]><BR>
Form.mygrid.original.col2[2]>
Editing data in cfgrid
To enable grid editing, specify the selectmode="edit" attribute. When enabled, a
user can edit cell data and insert or delete grid rows. When the user submits a cfform
containing a
cfgrid, data about changes to grid cells gets returned in the
one-dimensional arrays described in the preceding section. You can reference these
arrays as you would any other ColdFusion array.
Note
For the sake of code brevity, the following example handles only three of the fields in
the Employee table. A more realistic example would, at a minimum, include all seven
of the table’s fields. You might also consider hiding the contents of the Emp_ID
column and automatically generating its value for new records, and displaying the
Department name, from the Departmt table, in place of the Department ID.