Last week while I was at cfunited I got a comment on an old post that went a little something like this.
You were working on an example to show how to click a row and show details. Is there anywhere I might see this example?This should be pretty easy, lets go ahead and build this out. Before we get started lets take a look at what we are trying to accomplish here. We will have a grid on the left with our first and last name and when you click on a record it will populate on the right in our form.
The first thing we need to do is create the basic layout for our app. For this example we are going to use the art gallery database that ships with ColdFusion. Here we are creating the query and the grid. What's important to note here that even though we are not displaying all of the records they need to be included in the grid. If we did not the columns would not be stored in the underlying ext data store.
Next we will create our details area. At the end of all of this code we will use ajaxOnLoad to call a javascript method when the page loads. Basically all we are doing here is getting our grid object and adding a row click event listener to it. When we click on a row we are getting the record from the underlying ext data store. That record basically contains a record object. An easy way to see what the record is made up of is to log it to the console. Finally I just wrote a convenient method for setting the value of the input field.
So now we have our layout setup we just need to glue everything together.
You can check out a working demo by clicking here.

#1 by Todd Rafferty on 8/2/10 - 9:33 PM
#2 by Dan Vega on 8/2/10 - 9:40 PM
#3 by Todd Rafferty on 8/3/10 - 5:21 AM
#4 by Andrew Scott on 8/26/10 - 1:03 AM
Can I suggest a better approach to this?
When getting the record it is actually best to this
var record = grid.getStore().getAt(index);
and then do this to get the data
setValue('artistid',record.get('ARTISTID'));
The reason for the getter is because the underlying property in this case data can and may change in the future. So it is best not to rely on this way of doing it.
Hope that helps.
#5 by Mickey on 8/27/10 - 9:47 AM
I can definitely see myself using this.
#6 by Matthew on 9/12/10 - 9:38 AM
THankd
#7 by Catbollu on 9/15/10 - 1:03 PM
Here is a new question
How would I go about clicking a row and it opening a web page to a link that is embedded in the cfgrid.
#8 by Wayne on 9/15/10 - 5:21 PM
This is what I've got:
<label for="cResource">Resource:</label>
<select name="cResource">
<cfoutput query="getResources">
<option value="#iIDResourceLU#"<cfif iIDResource EQ iIDResourceLU> selected="selected"</cfif>>#trim(cResource)#</option>
</cfoutput>
</select>
How do I reference the iIDResource value that's coming from the script in the header:
setValue('iIDResource',record.IIDRESOURCELU);
Thanks much!
#9 by mona on 3/17/11 - 1:15 PM
How can I use this example to open details in a modal window? Thanks
#10 by Vince on 6/22/11 - 1:26 PM
#11 by Peter on 8/19/11 - 11:02 AM
#12 by Mikel on 9/8/11 - 7:36 AM
var record = grid.getStore().getAt(index).data;
For CF8 use this instead:
var record = grid.getSelections()[0].data;
I did this a while ago so I believe that was all that I had to change but there may have been other changes as well....