Skip to main content
April 17, 2010
Question

CF9 cfgrid array all mixed up on editing?

  • April 17, 2010
  • 2 replies
  • 1715 views

I have a cfgrid that is editable.  Two colums are visible, one is the primary key and is not visible or selectable.

Upon making an edit to a row, submitting the form and doing a cfdump of the form, something very odd is apparent:

This is when the grid is first populated.

query
CFGRIDROWINDEXIDIDTYPEID_ID
110000WGN11093

I change the value of ID to 0001 and leave everything else the same (ID_ID is the pk). Upon submitting the form and doing a quick cfdump before anything is updated to the db...

IDGRID.ID
array
111093
IDGRID.IDTYPE
array
10000
IDGRID.ID_ID
array
111093
IDGRID.ORIGINAL.ID
array
10001
IDGRID.ORIGINAL.IDTYPE
array
1WGN
IDGRID.ORIGINAL.ID_ID
array
111093
IDGRID.ROWSTATUS.ACTION
array
1U

The values are all messed up.  grid.original.id actually has the updated value.  And it mistakenly puts the orignal value into an updated value for idtype.

This ends up updating the wrong fields in my db!

What the heck?

    This topic has been closed for replies.

    2 replies

    Known Participant
    June 5, 2010

    Thanks to stuttsdc I was able to get this working. Here is a bit more information.  Not only must the primary key be selectable (a huge problem that I hope will be in a hot fix soon), but any column to the left of a column being edited must also be selectable. So in other words, if you have 6 columns and want column 5 to be editable, the prior four must also be editable.

    I am going to try putting the primary key to the far right, set it as not selectable, to see if this works. Just haven't had time yet.

    Inspiring
    June 5, 2010

    Could you pls post some simplified stand-alone code that demonstrates this issue?  Cheers.

    --

    Adam

    Participant
    June 29, 2010

    What I've found is that all display=false select=no fields need to be to the right of any editable columns.  If not, all hell breaks loose when the grid gets submitted.

    This is a pretty big bug imo.

    @Adam - below is some sample code and some screen shots.  Be sure to click the "insert" button on the grid to add a new record.  I am currently just running the Developer edition (9,0,0,251028) on a Windows 2003 server.

    - Tim


    <!--- Dump form fields --->
    <cfdump var="#form#"><br>

    <!--- define form --->
    <cfform name="testForm" id="testForm" format="html">

        <!--- define grid --->
        <cfset args = structNew()>
        <cfset args.name="testGrid">
        <cfset args.format="html">
        <cfset args.selectmode="edit">
        <cfset args.insert="yes">
        <cfgrid attributeCollection="#args#">
            <cfgridcolumn name="id"     header="Internal ID" display="false" select="no" >
           
            <cfgridcolumn name="name"     header="Name"     type="string_noCase" >
            <cfgridcolumn name="age"     header="Age"     type="numeric">
        </cfgrid>

        <!--- submit button --->
        <br><cfinput type="submit" name="submitBtn">

    </cfform>

    April 18, 2010

    I've managed to narrow down the issue.

    In the grid, if the column holding the hidden field (the pk) is set to select='no' (which is what's needed), the problem happens.

    Setting it to 'yes' or not including it will get rid of the problem and the grid updates fine.

    That's an issue though b/c I don't want to user messing w/the pk field.

    help..?    

    Known Participant
    June 4, 2010

    I have the same problem. Seems like a pretty big bug to me. Except I don't see any change by making the key field selectable; mine are still hosed.