Skip to main content
August 5, 2010
Question

How Update 2 Tables from a Grid - CF 9

  • August 5, 2010
  • 5 replies
  • 958 views

Is there a way to do this in CF 9?

Some of the grid columns need to update the table "contract".
The update code for the other table, "fte" is below. It will
fail, obviously, since several columns in the update query
belong to the "contract" table.

Here's the relevant code:

GetRCPsForContracts.UpContract.cfc

  <cffunction name="UpContract" access="remote"> 
     <cfargument name="gridaction" type="string" required="yes">
      <cfargument name="gridrow" type="struct" required="yes">
       <cfargument name="gridchanged" type="struct" required="yes">                         

        <cfset var qUP  = "" />
                 <!--- Get column name and value --->
                 <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                 <cfset value=ARGUMENTS.gridchanged[colname]>
                          
                 <!--- Perform update --->             
                    <cfquery name = "qUP" datasource="#request.ATCdsn#">
                 UPDATE fte
                 SET #colname# = '#value#'
                 WHERE FTE_id = #ARGUMENTS.gridrow.FTE_id#
                 </cfquery>              
</cffunction>

ContractMngmnt.cfm

   <cfform  name="Contract_EDIT">

       <cfgrid name= "Contract_EDIT"
          title="Please update the following Contract/Task Information for your RCP"
          selectmode="edit"    
          insert="no"
          format="html"
          striperows="yes"
          bindonload="no"
          bind="cfc:ATC._cfc.GetRCPsForContracts.ChosenContract({cfgridpage},
        {cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},  {RCPContracts.CTR_ID}, {RCPContracts.FTE_id}, {RCPContracts.clin_id})"
   onChange="cfc:ATC._cfc.GetRCPsForContracts.UpContract({cfgridaction},
                                                     {cfgridrow},
                                                     {cfgridchanged}
                                                    )">
            <cfgridcolumn name="contract_number" header="Contract ##">                                    
           <cfgridcolumn name="to_number" header="Task Order ##">
           <cfgridcolumn name="award_date" header="Award Date">
           <cfgridcolumn name="clin" header="CLIN" display="yes">
           <cfgridcolumn name="pop_start" header="POP Start">
           <cfgridcolumn name="pop_end" header="POP End">
           <cfgridcolumn name="price" header="Unit Price">
           <cfgridcolumn name="" header="Number of Units">
           <cfgridcolumn name="units_description" header="Unit Description">
           <cfgridcolumn name="total" header="Total Price">          
          </cfgrid> 
    </cfform>

Thanks for any assistance you can provide.

Blue-Cloud

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

August 9, 2010

I tried what I thought was the "old-fashioned" way, by

using a submit button and going to a cfm page that

checked if the submission was a "U" by looping through

the rowstatus.action of the form. That didn't work b/c

I needed an "onChange" to go with the "bind" parameter.

The code I sent my forum post didn't work with the above

method either.

Do I need to break apart the ExtJS that underlies the

"onChange" event to update 2 tables from the grid?

Thanks for any assistance.

Blue-Cloud

Inspiring
August 9, 2010

Actually, it might be quite simple.

In your function, create two lists.  Each will contain the fields associated with each table.  When you call the function, see what list the gridcolumn is in and update that table.

August 9, 2010

Could you provide some pseudo code to illustrate what you mean?

Thanks for your help, Dan.

Inspiring
August 5, 2010

You can always do it the old fashioned way.  Submit the form and write the necessary queries to do the necessary work.