CFGrid that opens external website when clicking on a row.

I have a database that has a URL field. The URL's can be different. This is what i currently have but nothing launches when i click on a row.
Thoughts?
<cfform name="video" format="html" align="center">
	<cfgrid name="videolist" query="videos" format="html" autowidth="no" selectmode="ROW" onchange="getURL('https://youtube.com/watch?='videolist.selectedItem.path, '_blank')">
		<cfgridcolumn name="vidname" header="Video Name" display="Yes" width="150"></cfgridcolumn>
		<cfgridcolumn name="software" header="Software" display="Yes" width="100"></cfgridcolumn>
		<cfgridcolumn name="keywords" header="Tags" display="Yes" width="300"></cfgridcolumn>
		<cfgridcolumn name="vidnumber" header="Number" display="Yes" width="100"></cfgridcolumn>
		<cfgridcolumn name="path" header="Location" display="Yes" width="300" ></cfgridcolumn>
		<cfgridcolumn name="dateadded" header="Date Entered" display="Yes" width="100"></cfgridcolumn>
	</cfgrid>
</cfform>

Open in new window

LVL 7
bcrosby007Asked:
Who is Participating?
 
_agx_Commented:
getURL() is actionscript, used with format="flash" only.

Using the "href" & "hrefkey" attributes would be perfect for this. Sadly CFGRID doesn't support custom URL parameter names.  Closest I could come was using the hack from here. Listener code updated for CF11.

Disclaimer: Adobe has a bad habit of updating the JS stuff without warning, so don't be surprised if it breaks in CF 2016.  May want to look into other libs for creating grids instead of using cfgrid.

<!--- demo query --->
<cfset videos = queryNew("")>
<cfset queryAddColumn(videos, "vidname", ["abc","efg","hij"])>
<cfset queryAddColumn(videos, "path", ["1111","2222","3333"])>

<html> 
<head> 
     <title>Grid URL Demo</title> 
     <script type="text/javascript"> 
     function init(){ 
         var grid = ColdFusion.Grid.getGridObject("videolist"); 
         grid.addListener("cellclick",oncellclick); 
     } 
     
	 function oncellclick (view, cell, cellIndex, record, row, rowIndex, e) {
		  var path = ColdFusion.getElementValue("videolist", "video", "path");
		  // REPLACE THIS WITH YOUR URL
		  window.open('https://youtube.com/watch?='+ path, '_blank');
     }
     
     </script>     
</head> 
<body>  

<cfform id="video" name="video" format="html" align="center">
	<cfgrid  name="videolist" query="videos" format="html" autowidth="no" selectmode="ROW">
		<cfgridcolumn name="vidname" header="Video Name" display="Yes" width="150"></cfgridcolumn>
		<cfgridcolumn name="path" header="Location" display="Yes" width="300"></cfgridcolumn>
	</cfgrid>
</cfform>
     <cfset ajaxOnLoad("init")>      
</body> 
</html>

Open in new window

0
 
bcrosby007Author Commented:
I ended up using jquery and a few other things to make it work.

Thanks for your help.
0
 
bcrosby007Author Commented:
Thanks.
0
 
_agx_Commented:
I ended up using jquery and a few other things to make it work.

Dropping cfgrid for an external lib is really the way to go.  CFGrid is notoriously .. painful to extend, and ... like I mentioned, Adobe tends to break custom grid features with every update. So you're better off with another grid tool.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.