View comments | RSS feed

cfgridupdate

Description

Used within a cfgrid tag. Updates data sources directly from edited grid data. This tag provides a direct interface with your data source.

This tag applies delete row actions first, then insert row actions, then update row actions. If it encounters an error, it stops processing rows.

Category

Forms tags

Syntax

<cfgridupdate 
grid = "gridname"
dataSource = "data source name"
tableName = "table name"
username = "data source username"
password = "data source password"
tableOwner = "table owner"
tableQualifier = "qualifier"
keyOnly = "yes" or "no">

See also

cfgrid, cfgridcolumn, cfgridrow, cfform, cfapplet, cfinput, cfselect, cfslider, cftextinput, cftree

History

ColdFusion MX: Deprecated the connectString, dbName, dbServer, dbtype, provider, and providerDSN attributes. They do not work, and might cause an error, in releases later than ColdFusion 5.

Attributes

Attribute Req/Opt Default Description

grid

Required

 

Name of the cfgrid form element that is the source for the update action.

dataSource

Required

 

Name of the data source for the update action.

tableName

Required

 

Name of the table to update.

For ORACLE drivers, entry must be upper-case.

For Sybase driver, entry is case-sensitive; must be same case as used when table was created.

username

Optional

 

Overrides username value specified in ODBC setup.

password

Optional

 

Overrides password value specified in ODBC setup.

tableOwner

Optional

 

Table owner, if supported.

tableQualifier

Optional

 

Table qualifier, if supported. Purpose:

  • SQL Server and Oracle driver: name of database that contains the table.
  • Intersolv dBASE driver: directory of DBF files.

keyOnly

 

no

Applies to the update action:

  • yes: the WHERE criteria are limited to the key values.
  • no: the WHERE criteria include key values and the original values of changed fields.

Example

The following example lets you update a database by using a cfgrid tag to add and delete entire records or to update the data in individual cells. The cfgridupdate tag processes the data from the submitted form and updates the database.

<!--- If the gridEntered form field exists, the form was submitted.
      Perform gridupdate. --->
<cfif IsDefined("form.gridEntered") is True>
   <cfgridupdate grid = "FirstGrid" dataSource = "cfdocexamples" Keyonly="true"
      tableName = "CourseList">
 </cfif>

<!--- Query the database to fill up the grid. --->
<cfquery name = "GetCourses" dataSource = "cfdocexamples">
SELECT Course_ID, Dept_ID, CorNumber,
     CorName, CorLevel, CorDesc
FROM CourseList
ORDER by Dept_ID ASC, CorNumber ASC
</cfquery>

<h3>cfgrid Example</h3>
<I>Try adding a course to the database, and then deleting it.</i>
<cfform>
<cfgrid name = "FirstGrid" width = "450" 
   query = "GetCourses" insert = "Yes" delete = "Yes"
   font = "Tahoma" rowHeaders = "No" 
   colHeaderBold = "Yes" 
   selectMode = "EDIT"
   insertButton = "Insert a Row" deleteButton = "Delete selected row" >
</cfgrid><br>
<cfinput type="submit" name="gridEntered">
</cfform>...

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


asus said on Mar 11, 2005 at 3:32 AM :
I found out that if no value in the grid has been updated, submitting the form will throw an error saying that the cfgrid_instance is not defined, even if dumping the form will show the cfgrid_instance.selectedRow etc...
I don't know if it is on purpose but I think it is a strange behavior.

Pim
PS: the form components are great!!!!
Igel said on Apr 23, 2005 at 8:12 AM :
looks like this cfgridupdate isn't working with format="flash" in MX7... applet works.
jrunrandy said on Apr 27, 2005 at 2:13 PM :
Igel,
This is in our bug tracking system as bug 60116.
Ro From IDB said on Apr 5, 2006 at 9:41 AM :
If you have a "Datetime" field in the database, and want to make the field NULL or Blank. on Update time, an "Invalid data for CFSQLTYPE CF_SQL_TIMESTAMP" is thrown. It seems cfgridupdate doesn't interpret empty fields as nulls.
No screen name said on Oct 30, 2008 at 9:31 PM :
As I understand it, a "NULL" field value is sent as "" unless you specify a default attribute in the "value" attribute of the form control.


<cfinput type="hidden"
name="Ts"
value="#Now()#"">

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000269.htm