Warning about cfgrid bug

This post is more than 2 years old.

This week I was working on a cfgrid example for a reader. He needed some help understanding the FORM data on the server side when you've done multiple edits to a grid (and if folks want me to pass along what I told him, just say). It's a bit complex so I wrote up a quick demo and explained how the form data related to what was done on the client side.

During this work I discovered an unfortunate bug with cfgrid and editable grids. If your grid supports deletes along with edits (by using delete="true" in the cfgrid tag), you can run into an issue where one of your edits will not be passed to the server. What I noticed was that if I edited rows A and B, and then deleted some row C, my form data included the edits for A and the delete for C, but completely lost the edit for B.

I was able to reproduce this in two browsers, and Adam Tuttle was able to reproduce it as well. I've file a bug report for it and if you want to quickly test this yourself, just try the code below.

Unfortunately there isn't really a workaround for this. For now I simply do not recommend using an editable grid that supports delete as well.

<cfquery name="art" datasource="cfartgallery" maxrows="10"> select * from art </cfquery> <cfform name="gridform1">

<cfgrid name ="test_data" format="html" font="Tahoma" fontsize="12" query = "art" selectmode="edit" striperows="yes" delete="true" > <cfgridcolumn name="artid" display="false" />

<cfgridcolumn name="artname" display="true" header="Art" select="no" /> <cfgridcolumn name="price" display="true" header="price" select="yes" /> <cfgridcolumn name="issold" display="true" header="Sold" select="no" /> <cfgridcolumn name="largeimage" display="true" header="largeimage" select="yes" />


<cfinput name="submit" type="Submit" value="Submit">


<cfdump var="#form#">

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Ahsan posted on 10/20/2010 at 6:10 PM

This happens because cfgrid which is inside cffrom uses aynchronous call ; internally using flash remoting. Depending on the frequency of click or edite or delete you are expected to see varying result because data may still be on the netowork pipeline.

Comment 2 by Raymond Camden posted on 10/20/2010 at 6:14 PM

I don't believe you are right. As far as I know it isn't doing any posts at all to the server, not till I hit submit.

Comment 3 by Raymond Camden posted on 10/20/2010 at 6:44 PM

Just tested with Charles and there were no Flash Remoting requests done in the background. To be clear, this is the Ajax grid, not the older Flash Form cfgrid.

Comment 4 by Ahsan posted on 10/20/2010 at 6:53 PM

You got me if you are using Ajax grid :)

Comment 5 by JP posted on 10/20/2010 at 10:23 PM

There's also a bug in older versions of safari... trapping for double click events doesn't work. I haven't found a work-around yet.

Comment 6 by Dale Fraser posted on 10/21/2010 at 6:08 AM

Can't tell you how disapointed with CGGRID we are, simple stuff just doesn't even with CF9.

Try doing a right aligned column that sorts numerically, one of the most common things you might do in a grid.

Comment 7 by Raymond Camden posted on 10/21/2010 at 3:53 PM

That's unfortunate. All I can recommend is jqGrid again - but I tend to go jQuery in almost every case. ;)