Adobe ColdFusion 8

Creating an editable 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.

You can let users add or delete grid rows by setting the insert or delete attributes in the cfgrid tag to Yes. Setting the insert and delete attribute to Yes causes the cfgrid tag to display Insert and Delete buttons as part of the grid, as the following image shows:

You can use a grid in 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 based on the form values returned by the cfgrid tag.
  • 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 the cfquery tag 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.