Nitobi
Customer Login
Services
Products
About
Blogs
Contact
Home -> Product Knowledgebase Order Online | Free Trial Downloads

Nitobi Product Knowledgebase

Saving Data (CFMX)


The Grid sends only the changes to data to the server for saving. It does this to save on bandwidth in order to maximize responsiveness and server performance.

First, include the Nitobi Coldfusion XML library:

<!--- We include the Nitobi CF XML library 1.0 --->
<cfinclude template = "nitobi.xml.cfm">

Next, make a call to EBASaveHandler_ProcessRecords() which grabs the updategram from the Ajax form post.

<CFOUTPUT>

  #EBASaveHandler_ProcessRecords()#

</CFOUTPUT>

Now we loop through our updategram instructions and perform all the necessary INSERT's, UPDATE's, and DELETE's.

<cfloop index = "InsertLoop" from = "1" to = #EBASaveHandler_ReturnInsertCount#>
 <cfquery datasource="NitobiTestDB" name="InsertRecord">
  INSERT INTO tblContacts3k (
   ContactName,
   ContactEmail,
   JobTitle,
   CompanyName,
   PhoneNumber,
   Address) VALUES (
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "ContactName")#',
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "ContactEmail")#',
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "JobTitle")#',
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "CompanyName")#',
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "PhoneNumber")#',
   '#EBASaveHandler_ReturnInsertField(InsertLoop, "Address")#')
 </cfquery>  
</cfloop>

Now we process our update records. EBA_PK is the primary key of the row.

<cfloop index = "UpdateLoop" from = "1" to = #EBASaveHandler_ReturnUpdateCount#>
 <cfquery datasource="NitobiTestDB" name="UpdateRecord">
  UPDATE tblContacts3k SET
   ContactName = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "ContactName")#',
   ContactEmail = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "ContactEmail")#',
   JobTitle = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "JobTitle")#',
   CompanyName = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "CompanyName")#',
   PhoneNumber = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "PhoneNumber")#',
   Address = '#EBASaveHandler_ReturnUpdateField(UpdateLoop, "Address")#'
   WHERE ContactID = #EBASaveHandler_ReturnUpdateField(UpdateLoop, "EBA_PK")#
 </cfquery> 
</cfloop>

Finish by processing our delete instructions..

<cfloop index = "DeleteLoop" from = "1" to = #EBASaveHandler_ReturnDeleteCount#>
 <cfquery datasource="NitobiTestDB" name="DeleteRecord">
  DELETE FROM tblContacts3k WHERE ContactID = #EBASaveHandler_ReturnDeleteField(DeleteLoop, "EBA_PK")#
 </cfquery>
</cfloop>

Finally, we complete the process by calling CompleteSave.

<cfscript>
 EBASaveHandler_CompleteSave();
</cfscript>

View Printable Version

Comments:


Name:

Type the text you see above:

Comments:


Knowledgebase

To be notified of new articles when they're available, subscribe to our RSS feed.

Support Resources

Take advantage of our knowledgebase of product tutorials and tips, and our support forums!

Search Site


Sign up for our Newsletter:

Get industry articles and Nitobi company news in your inbox every couple of months — here's a sample!

Email:




Site RSS Feed  | All contents are (c) Copyright 2006, Nitobi Software Inc. All rights Reserved