User Guide

cfgrid 157
Simple selection data (SelectMode = Single, Column, or Row)
The data that form variables return to the
cfform's action page contains information about
which cells the user selected. In general, ColdFusion makes this data available in the action page,
as ColdFusion variables in the Form scope, with the naming convention
form.#GridName#.#ColumnName#
Each SelectMode returns these form variable(s):
SelectMode="single"
form.#GridName#.#ColumnName# = "SelectedCellValue"
SelectMode="column"
form.#GridName#.#ColumnName# = "ValueOfCellRow1,
ValueOfCellRow2, ValueOfCellRowN"
SelectMode="row"
form.#GridName#.#Column1Name# = "ValueOfCellInSelectedRow"
form.#GridName#.#Column2Name# = "ValueOfCellInSelectedRow"
form.#GridName#.#ColumnNName# = "ValueOfCellInSelectedRow"
Complex update data (SelectMode = Edit)
The grid returns a large amount of data, to inform the action page of inserts, updates or deletes
that the user made to the grid. In most cases, you can use the
cfgridupdate tag to automatically
gather the data from the form variables; the tag collects data, writes SQL calls, and updates the
data source.
If you cannot use
cfgridupdate (if, for example, you must distribute the returned data to more
than one data source), you must write code to read form variables. In this mode, ColdFusion
creates the following array variables in the Form scope for each
cfgrid:
form.#GridName#.#ColumnName#
form.#GridName#.original.#ColumnName#
form.#GridName#.RowStatus.Action
Each table row that contains an update, insert, or deletion has a parallel entry in each of these
arrays. To view all the information for all the changes, you can traverse the arrays, as in this
example:
<cfloop index="ColName" list="#ColNameList#">
<cfif IsDefined("form.#GridName#.#ColName#")>
<cfoutput><br>form.#GridName#.#ColName#:<br></cfoutput>
<cfset Array_New = evaluate("form.#GridName#.#ColName#")>
<cfset Array_Orig = evaluate("form.#GridName#.original.#ColName#")>
<cfset Array_Action = evaluate("form.#GridName#.RowStatus.Action")>
<cfif NOT IsArray(Array_New)>
<b>The form variable is not an array!</b><br>
<cfelse>
<cfset size = ArrayLen(Array_New)>
<cfoutput>
Result Array Size is #size#.<br>
Contents:<br>
</cfoutput>
<cfif size IS 0>
<b>The array is empty.</b><br>
<cfelse>