21 Nov, 2007
ColdFusion 8 HTML CFGrid href attribute with JavaScript function
Posted by: Donnie Bachan In: ColdFusion| Javascript
I was going crazy trying to figure out why my href in the cfgridcolumn tag was not working with the new CFGrid in html mode. Apparently the appendKey attribute of the CFGrid tag is set to TRUE by default and this forces the href attribute to be a valid url. If you change the appendKey to FALSE, javascript functions work in the cfgridcolumn tags just fine….
So:
<code>
<cfform>
<cfgrid format=”html” name=”gContentLibrary” pagesize=”#request.maxrows#”
bind=”url:…”
>
<cfgridcolumn name=”title” href=”javascript:makeRequest(’viewlibraryitem’,{gridid:’gContentLibrary’})” display=”true” header=”Object Title” width=”250″ />
</cfgrid>
</cfform>
</code>
will not work but
<code>
<cfform>
<cfgrid format=”html” name=”gContentLibrary” pagesize=”#request.maxrows#”
bind=”url:…”
appendKey = “no”
>
<cfgridcolumn name=”title” href=”javascript:makeRequest(’viewlibraryitem’,{gridid:’gContentLibrary’})” display=”true” header=”Object Title” width=”250″ />
</cfgrid>
</cfform>
</code>
will work.
I may be stupid but it took a long time for me to figure this out and I didn’t even find a reference to this on Google….either, people aren’t doing this or everyone is much smarter than I am! Anyway I hope it helps someone out there…