Ruben_Jimenez
asked on
URGENT - CFGrid array problem
Using Coldfusion 8, I was attempting to use CFGRID and CFGRIDUPDATE to update records in my SQL server, but the update would not update the records. Further review showed that what's contained in the array fields do not match associated fields. I've attached a screen shot of result and the associated code. I coulldn't find any problems like this in the site. Notice that the same value appears twice for each successive fields. What's that about?
Please help!
Please help!
<cfif #IsDefined('form.Submit')#>
<cfloop index="Row" From="1" to="#ArrayLen(form.Instruct.RowStatus.Action)#">
<cfif #form.Instruct.RowStatus.Action[row]# eq 'U'>
<cfoutput>Row - #Row#<br />
Discretionary - #form.Instruct.Discretionary[Row]#<br />
Organization - #form.Instruct.Organization_Code[Row]#<br />
Fund - #form.Instruct.Fund[Row]#<br />
Function - #form.Instruct.Function_Code[Row]#<br />
Object - #form.Instruct.Object[Row]#<br />
Sub-Object - #form.Instruct.Sub_Object_Code[Row]#<br />
PIC - #form.Instruct.PIC[Row]#<br />
Description - #form.Instruct.Description[Row]#<br />
LY - Budget - #form.Instruct.Last_Year_Budget[Row]#<br />
LY - Actual - #form.Instruct.Last_EOY_Actual[Row]#<br />
Requested - #Form.Instruct.Amount_Requested[Row]#
</cfoutput>
</cfif>
</cfloop>
</cfif>
<cfquery name="Worksheet_11" datasource="Budget" dbtype="odbc">
SELECT Campus_Worksheets.*
FROM Campus_Worksheets
WHERE Campus_Worksheets.[Organization_Code] = '101' and (Discretionary = 1) and [Function_Code] = '11'
ORDER BY Discretionary, Organization_Code, Fund, Function_Code, Object, Sub_Object_Code, PIC
</cfquery>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<cfform>
<cfgrid name= "Instruct" format="html" striperows="yes" query="Worksheet_11" selectmode="Edit" colheaderbold="yes" insert="yes" insertbutton="Insert">
<cfgridcolumn name="Discretionary" header="Discretionary" display="no" width="5" select="no">
<cfgridcolumn name="Organization_Code" header="Organization_Code" display="no" width="5" select="no">
<cfgridcolumn name="Fund" header="Fund" width="35" select="no">
<cfgridcolumn name="Function_Code" header="Func" width="35" select="no">
<cfgridcolumn name="Object" header="Object" width="50" select="no">
<cfgridcolumn name="Sub_Object_Code" header="SubObj" width="50" select="no">
<cfgridcolumn name="PIC" header="PIC" width="35" select="no">
<cfgridcolumn name="Description" header="Description" width="250" select="no">
<cfgridcolumn name="Last_Year_Budget" header="LY Budget" width="75" select="no">
<cfgridcolumn name="Last_EOY_Actual" header="LY Actual" width="75" select="no">
<cfgridcolumn name="Amount_Requested" header="Requested" width="75" select="yes" type="numeric">
</cfgrid>
<br />
<cfinput type="submit" name="Submit" value="Submit">
<br />
</cfform>
</body>
</html>
Coldfusion-Error.docx
ASKER
Looking through other questions/comments on this site regarding CFGRID and CFGRIDUPDATE, it appears to have worked. What is different and are there any suggestions of a workaround. I have 8 grids that need to be created and updated, so ideally this would be the best format for presentation. If I could give 1000 points I would!
i am pretty sure it worked before...
i had run the cfgridupdate tests when cf8 came out in 2007, and apparently it worked just fine...
so maybe it's one of later updates/hotfixes that broke it?
i will try running more tests tomorrow. there are so many possible variables in this that it will take some time to figure this one out.
did you try posting about this in adobe's cf peer forums or on houseoffusion's cf-talk list?
Azadi
i had run the cfgridupdate tests when cf8 came out in 2007, and apparently it worked just fine...
so maybe it's one of later updates/hotfixes that broke it?
i will try running more tests tomorrow. there are so many possible variables in this that it will take some time to figure this one out.
did you try posting about this in adobe's cf peer forums or on houseoffusion's cf-talk list?
Azadi
ASKER
I've been searching for solutions or workarounds for this problem and I'm amazed that it appears no one has had this problem! This tag is exactly what I need for my application since users would have to be able to add items as well as update existing records.
Someone out there has had to face this before - any suggestions would be greatly appreciated and rewarded.
Someone out there has had to face this before - any suggestions would be greatly appreciated and rewarded.
hmm... i just noticed something while trying to solve another cfgrid question:
if you use custom grid renderers - i.e. re-render the cfgrid after it has been loaded - this adds a hidden field to the form with the same name as an already existing hidden field which was added on initial grid load.
that could explain why you are seeing duplicate data... that is if you are using custom renderers for your cfgrid...
Azadi
if you use custom grid renderers - i.e. re-render the cfgrid after it has been loaded - this adds a hidden field to the form with the same name as an already existing hidden field which was added on initial grid load.
that could explain why you are seeing duplicate data... that is if you are using custom renderers for your cfgrid...
Azadi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://forums.adobe.com/message/2935249 helped me resolve a similar issue
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.
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 just re-ran some tests on editable html cfgrid - straight from livedocs example for <cfgridupdate> tag - and man is it weird!
the results were not exactly as yours - i did not get any repeated values for different grid columns - but it definitely updated wrong rows with wrong data; that is when it actually correctly saw the rows that were updated (sometimes when 3 rows were updated only 2 [and usually incorrect] rows were present in the form structure as updated). a lot seems to depend on what you click on inbetween and after updating rows... but exactly HOW that relates to which rows get submitted with the grid as updated and WHY wrong rows are sent i can't seem to grasp...
sorry i could not help you with your problem. but for my part i officially declare editable cfgrids dead for me...
Azadi