A couple weeks ago I wrote an tutorial on how to create a custom Grid Editor. The tutorial explained how you could tap into the power of Ext to create a select menu editor. In the example we used state as the edit field. This is a perfect example of where you would want to pick from a list rather than key in your answer. It has come to my attention that this functionality is baked right in to ColdFusion 8. This raises 1 important question for me, is nobody is reading my articles or did nobody know this was baked in?
So to get started with this tutorial you need a little knwoledge of how editing works with the html grid. Lucky for you I wrote a quick start on basic editing using the grid. The following code should look pretty similair if you have been following along. Here we are just running a query and setting up some basic properties for our grid. If you double click in any of the cells you should be able to edit the data.
2 SELECT artistId, firstname, lastname, address, city, state, postalcode, email
3 FROM Artists
4 </cfquery>
5
6 <cfset args = structNew()>
7 <cfset args.name = "ArtistGrid">
8 <cfset args.format = "html">
9 <cfset args.query = "getArtists">
10 <cfset args.stripeRows = true>
11 <cfset args.selectColor = "##D9E8FB">
12 <cfset args.selectmode = "edit">
13 <cfset args.onchange = "cfc:artists.editArtist({cfgridaction},{cfgridrow},{cfgridchanged})">
14
15 <cfform>
16 <cfgrid attributeCollection="#args#">
17 <cfgridcolumn name="artistid" display="false">
18 <cfgridcolumn name="firstname" header="First Name">
19 <cfgridcolumn name="lastname" header="Last Name">
20 <cfgridcolumn name="email" header="Email Address">
21 <cfgridcolumn name="address" header="Address">
22 <cfgridcolumn name="city" header="City">
23 <cfgridcolumn name="state" header="State" >
24 </cfgrid>
25 </cfform>
- select - Determines selection behavior if the cfgrid selectmode attribute value is column, edit, or single; ignored for row or browse values.
- values - Formats cells in column as drop-down list boxes; specify items in drop-down list, for example: values = "arthur, scott, charles, 1-20, mabel"
- valuesDisplay - Maps elements in the values attribute to string to display in the drop-down list. Delimited strings and/or numeric ranges.

#1 by todd sharp on 3/28/08 - 3:45 PM
#2 by todd sharp on 3/28/08 - 3:46 PM
#3 by Zane on 4/2/08 - 8:48 AM
Thanks for all your posts! They have gotten me up and running with CF extremely fast. I've been following your posts on cfgrid and one thing I haven't seen yet is how you would pass the cfgrid change data to a javascript for processing via cfajaxproxy? My problem is like this:
I have it setup so that when they select the item a dropdown menu comes up and they can change the item details. The problem is that it references a foreign key and when it does the onchange event it does the update but leaves the ugly number in there instead of what it is referencing. I've tried for the last couple days to get it to pass the required onchange variables to javascript and then have the javascript do a grid refresh but when I try and pass it from javascript to the cfc it breaks (the 3 variables show up as "U", and then many 'null' values for cfgridrow and cfgridchanged). Is there a way to pass the cfgridrow and cfgridchanged variables to javascript via the onchange command? I hope this makes sense, as this is the only place i've found that even comes close to answering these questions!
#4 by vinnyp on 5/1/08 - 11:59 PM
#5 by Dan Vega on 5/2/08 - 8:05 AM
#6 by vinnyp on 5/5/08 - 3:04 PM
#7 by Carla Scepaniak on 6/4/08 - 6:06 PM
#8 by steve on 7/18/08 - 2:32 AM
#9 by Regina on 8/19/08 - 1:55 PM
Does this only work for applet cfgrids? Mine is html and I don't see the dropdown. Help!
#10 by Dan Vega on 8/19/08 - 1:57 PM
#11 by S on 8/21/08 - 1:38 PM
#12 by Zane on 8/21/08 - 1:43 PM
#13 by Dan Vega on 8/21/08 - 1:48 PM
#14 by S on 8/21/08 - 2:52 PM
#15 by Giedrius on 9/22/08 - 1:35 PM
Both display <div class="x-grid-col-7 x-grid-cell-inner"><div class="x-grid-cell-text" unselectable="on"> </div></div> when double clicked, too.
Great tutorials!
#16 by ADS on 12/2/08 - 11:15 AM
#17 by Dan Vega on 12/2/08 - 2:26 PM
#18 by Hammergood on 12/11/08 - 8:06 AM
Quote:
#6 Posted By: vinnyp Posted On: 5/5/08 3:04 PM
It is a bug with Coldfusion 8.01 that they are working on a hot fix for now.
#19 by jono on 12/12/08 - 11:32 AM
#20 by Jason on 2/25/09 - 7:39 AM
#21 by Gary Habermann on 2/26/09 - 1:08 PM
Thank you
Gary
#22 by zaher on 4/16/09 - 5:48 PM
but i have a problem. whenevr i choose a value from the dropdown list and i want to change this value to another one, the dropdwon list only shows me the value that i selected the first time and all other values disappears.
can you help in thta?
Thanks
#23 by Dan on 6/18/09 - 1:31 PM
#24 by Dan on 6/18/09 - 1:36 PM