Link a grid row to a url
The CFGrid applet version has a property called href which allows you to link a grid column to a URL. However, this didn't make it into the flash grid for this release (it is high on the enhancement request).
But there is a way, using the onChange attribute of cfgrid and some simple actionscript you can link a selected row to a url.
Thanks to Jared Chandler for this example.
-----------------
onchange="getUrl('test.cfm?user_id=' + linkGrid.dataProvider[linkGrid.selectedIndex]['id']);"
Full Example:
------------
<cfif isDefined("url.user_id")>
<cfoutput>
<p>The selected userid is: #url.user_id#</p>
</cfoutput>
</cfif>
<cfscript>
myData = queryNew("id,name");
queryAddRow(myData);
querySetCell(myData, "id", "a001");
querySetCell(myData, "name", "John Doe");
queryAddRow(myData);
querySetCell(myData, "id", "a002");
querySetCell(myData, "name", "Jane Doe");
queryAddRow(myData);
querySetCell(myData, "id", "b001");
querySetCell(myData, "name", "Mike Smith");
queryAddRow(myData);
querySetCell(myData, "id", "c001");
querySetCell(myData, "name", "Bob Jones");
</cfscript>
<cfform format="Flash" width="500" height="400">
<cfgrid name="linkGrid" query="myData"
onchange="getUrl('test.cfm?user_id=' + linkGrid.dataProvider[linkGrid.selectedIndex]['id']);">
<cfgridColumn name="id" header="userid">
<cfgridColumn name="name" header="User Name">
</cfgrid>
</cfform>

I have found an issue and was wondering if this is by design. When I bind a data field (id) that is an integer, it won't work. Switch to a string (varchar) no problem.
<cfform format="Flash" width="500" height="400">
<cfgrid name="linkGrid" query="reportListing"
onchange="getUrl('#ReportName#.cfr?ReportListingID=' + linkGrid.dataProvider[linkGrid.selectedIndex]['ReportListingID']);">
<cfgridColumn name="ReportListingID" header="ReportListingID" display="no">
<cfgridColumn name="ReportName" header="Report Name">
</cfgrid>
</cfform>
I have a question and an answer?
My question is how to display text in a datagrid as ?underline? and only for one or two columns?
This is for David
This is what I use to determine what columns is press?
_global.ListenerCellPress = Object();
_global.ListenerCellPress.cellPress = function(EventObject)
{
var strTileTitle = "";
switch(mydatagrid.getColumnAt(EventObject.columnIndex).columnName)
{
case "ColumnName 1":
your code goes here?
break;
case "ColumnName 2":
your code goes here?
break;
default:
break;
};//End of switch(mydatagrid.getColumnAt(EventObject.columnIndex).columnName)
this will also help with the onChange, because nothing have changed and the function is call only when you press on the column and this is why I need to know how to set the text as underline.
excelente articulo...
Thank you for sharing your knowledge. I'm currently
using your example, but my link is pointing to an XFDL
file extension. Is there away for CF to recognize this file
extension?