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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.