4

I have a simple cfgrid that's displaying my ids. I want the id to be a link to a new page, passing a url parameter of "myID" with the id value.

I've tried this code:

<cfgrid name="myGrid" query="myQuery" format="html">
   <cfgridcolumn name="myID" href="mynewpage.cfm" />
</cfgrid>

But this takes me to the url "mynewpage.cfm?hrefkey=111". What I really want is "mynewpage.cfm?myID=111". Is there any way to specify what the name of the url parameter should be?

I've also tried:

<cfgrid name="myGrid" query="myQuery" format="html">
   <cfgridcolumn name="myID" href="mynewpage.cfm?myID=#myID#" />
</cfgrid>

But then I get the error "myID is not defined". Is there any way to reference query field values from within a cfgridcolumn tag?

UPDATE:

Another thing I've tried - building the string in the sql query so that I return a column called myURL with a value of "mynewpage.cfm?myID=111", and then using that column for the href attribute:

<cfgrid name="myGrid" query="myQuery" format="html">
   <cfgridcolumn name="myID" href="#myURL#" />
</cfgrid>

According to the coldfusion documentation you should be able to do this:

href - URL or query column name that contains a URL to hyperlink each grid column with.

(italics mine)

But I get the error "myURL is not defined". How do I set the href to a column rather than a literal url value?

froadie
  • 79,995
  • 75
  • 166
  • 235
  • I did a brief search and only found threads [like this](http://forums.adobe.com/thread/510290) or [this one](http://forums.forta.com/messages.cfm?threadid=C72175F0-0974-85CE-B1052899FF1E9AAD) which seem to indicate it is not possible. (Maybe by tapping into the extjs stuff?) – Leigh Jan 14 '13 at 21:03

2 Answers2

1

This is similar to the <cftree>/<cftreeitem> problem using href. There does not seem to be a built-in solution for this. Either you deal with the provided keys and rename the whole address using outbound URL rewrite (IIS has native support, Apache can do this with UrlRewriteFilter), or you might just switch to a different Javascript based grid.

Leigh
  • 28,765
  • 10
  • 55
  • 103
Alex
  • 7,743
  • 1
  • 18
  • 38
  • Or you can set the href="#CGI.SCRIPT_NAME#", look for URL.CFGRIDKEY, and then do a cfheader to bounce the user to myURL, setting the myID part of the query string to #URL.CFGRIDKEY# – Tony Miller Jan 15 '13 at 19:41
0

One solution is in this page:

http://www.houseoffusion.com/cfdocs1/Developing_Web_Applications_with_ColdFusion/14_Building_Dynamic_Forms/dwa14_09.htm

Define a new column using

<cfset queryAddColumn(SPEREQ_QRY_UNFULFILLED, "CUST_LINK", ArrayNew(1)) />

<cfloop query="SPEREQ_QRY_UNFULFILLED">
  <cfset querySetCell(SPEREQ_QRY_UNFULFILLED, "CUST_LINK","index.cfm?action=contact_info&cust_id=#SPEREQ_QRY_UNFULFILLED.CUST_CNTCT_LMS_ID#", SPEREQ_QRY_UNFULFILLED.currentRow) />
</cfloop>

use this new column cust_link in the display

<cfgridcolumn name = "CUST_CNTCT_LMS_ID" header="CustID"  
     href="CUST_LINK" target="_blank" width="20">
<CFGRIDCOLUMN NAME="CUST_LINK" DISPLAY="No">
Leigh
  • 28,765
  • 10
  • 55
  • 103
Suman
  • 1
  • Why on earth are you pointing to CF4/4.5 documentation? It is over a decade old, and is probably referring to applets (yipes ;-) not `format=html`... – Leigh Nov 19 '13 at 16:58