Copy link to clipboard
Copied
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 | ||||
---|---|---|---|---|
CFGRIDROWINDEX | ID | IDTYPE | ID_ID | |
1 | 1 | 0000 | WGN | 11093 |
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 |
| ||||
IDGRID.IDTYPE |
| ||||
IDGRID.ID_ID |
| ||||
IDGRID.ORIGINAL.ID |
| ||||
IDGRID.ORIGINAL.IDTYPE |
| ||||
IDGRID.ORIGINAL.ID_ID |
| ||||
IDGRID.ROWSTATUS.ACTION |
|
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?
Copy link to clipboard
Copied
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..?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Could you pls post some simplified stand-alone code that demonstrates this issue? Cheers.
--
Adam
Copy link to clipboard
Copied
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>