Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Does cfgrid in v10 really return valid data in the form array?

$
0
0

Glad to.

 

First of all, create a table in an Access database:

          MDSESSIONS (

          ID Autonumber,

          SessName default alphanumeric datatype,

          SessDesc default alphanumeric datatype

          )

 

Populate 3 rows with SessName only, ID assigned by Access, SessDesc empty:

          Dairy Goats (ID = 2)

          Beekeeping (ID = 3)

          Chickens (ID = 4)

 

EDITGRID.CFM

<cfquery name="getStuff" datasource="utility">

          select id, sessname, sessdesc

          from mdsessions

          order by id

</cfquery>

 

<html>

<head>

          <title>Edit Sessions</title>

</head>

 

<body><br>

 

<cfform action="editpost.cfm" method="POST" format="html" target="_blank">

<cfgrid name="stuff" query="getStuff" selectmode="EDIT" format="html">

          <cfgridcolumn name="id" display="yes">

          <cfgridcolumn name="sessname" width="300">

          <cfgridcolumn name="sessdesc" width="300">

</cfgrid>

<br><cfinput type="submit" value="Post The Changes" name="submit">

</cfform>

 

<br></body>

</html>

 

EDITPOST.CFM

<html>

<head>

          <title>Edit Array</title>

</head>

 

<body>

 

<cfif structKeyExists(form,"submit")>

          <cfloop index = "counter" from = "1" to = #arraylen(Form.stuff.rowstatus.action)#>

                    <cfoutput>

                    Row #counter#

                    Action = #Form.stuff.rowstatus.action[counter]#

                    ID = #Form.stuff.id[counter]#

 

  <cfif #Form.stuff.original.sessname[counter]# neq #Form.stuff.sessname[counter]#>

    Name changes from #Form.stuff.original.sessname[counter]#

                                               to #Form.stuff.sessname[counter]#

  </cfif>

 

  <cfif #Form.stuff.original.sessdesc[counter]# neq #Form.stuff.sessdesc[counter]#>

    Description changes from #Form.stuff.original.sessdesc[counter]#

         to   #Form.stuff.sessdesc[counter]#

                    </cfif>

                    </cfoutput>

                    <br>

          </cfloop>

<cfelse>

          No form data

</cfif>

 

<cfdump var="#form#">

 

</body>

</html>

 

EditGrid.CFM displays 3 rows, in ID sequence: 2, 3, 4.

 

Click in the description for the 1st row and enter "a".

Click in the description for the 2nd row and enter "b".

Click in the description for the 3rd row and enter "c".

 

Click the [Post The Changes] button, and EditPost.CFM will load in a new tab/window.

 

EditPost.CFM displays two rows, not three:

Row 1 Action = U ID = 3 Description changes from to a

Row 2 Action = U ID = 4 Description changes from to c

 

So the ID's are wrong, and the description 'b' is not even represented in the form array.

 

Thanks!


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>