CFGRID : POP UP Via Link?

Hi,
I am using a CFGRID table on a a page populated using a cfc.  I have a column link that I'd like to invoke a JQuery function that a team member wrote that creates a modal popup window greying out the background (you know the kind) when a button/link is hit.

Q: How would I invoke this jquery function (or js function) from a cell in a CFGRID table that has a link associated with the cell (eg :"renew subscribtion").  Is it possible?

Thanks in advance,
hefterr
LVL 1
hefterrAsked:
Who is Participating?
 
reitersConnect With a Mentor Commented:
Give this a shot.  Its not pretty but should work for ya.
<cfcomponent>


<!--- Browse Subscription History for CFGRID --->
 <cffunction name="subscriptions"
             access="remote"
             returntype="struct"
             hint="Browse method for Ajax grid">
   <cfargument name="page"
               type="numeric"
               required="yes">
   <cfargument name="pageSize"
               type="numeric"
               required="yes">
   <cfargument name="gridsortcolumn"
               type="string"
               required="no"
               default="">
   <cfargument name="gridsortdir"
               type="string"
               required="no"
               default="">
                         

   <!--- Local variables --->
   <cfset var getOrderHist ="">

   <cfquery name="getOrderHist" datasource="#application.dsn#">
     Select  convert(varchar, OrderDate, 106) as ODate,
      'American Corporate Statistical Library. Spencers Greatest Ideas - Volume 1 (autographed copy)' as OrderId,
      ItemsOrdered,
      '$' + Convert(Varchar, Convert(Money,TotalDue),1)  as Total,
      'Click Here' as Renew,
      'Click Here' as Cancel,
      'Quarterly' as Period from Orders
       where Custno = 1000
       and Status  = 2
             
    
	<cfif ARGUMENTS.gridsortcolumn NEQ ""
         and ARGUMENTS.gridsortdir NEQ "">
      ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir#
    </cfif>
   </cfquery>
   
   <cfset foo = querynew('oDate,OrderId,ItemsOrdered,Total,Renew,Cancel,Period')>
   <cfloop query="getOrderHist">
      <cfset queryaddrow(foo)>
	  <cfset querysetcell(foo,'oDate',getOrderHist.oDate)>
	  <cfset querysetcell(foo,'OrderId',getOrderHist.OrderId)>
	  <cfset querysetcell(foo,'ItemsOrdered',getOrderHist.ItemsOrdered)>
	  <cfset querysetcell(foo,'Total',getOrderHist.Total)>
	  <cfset querysetcell(foo,'Renew','<a href="javascript: void(0);" onclick="pop_renew_window(some_key_value);">Click Here</a>')>
	  <cfset querysetcell(foo,'Cancel','<a href="javascript: void(0);" onclick="pop_cancel_window(some_key_value);">Click Here</a>')>
	  <cfset querysetcell(foo,'Period',getOrderHist.Period)>
   </cfloop>

   <!--- And return it as a grid structure --->
   <cfreturn QueryConvertForGrid(foo,
                                 ARGUMENTS.page,
                                 ARGUMENTS.pageSize)>
 </cffunction>


</cfcomponent>

Open in new window

0
 
leakim971PluritechnicianCommented:
Do you have a simple page with a cfgrid to propose ?
0
 
hefterrAuthor Commented:
Hi leakim971,
I have attached the basic CFGRID page and the associated CFC (next post)

You can run run the code via : http://smmc.centrispoint.com/test_CFGRID.cfm  .

I just want to be able to invoke some Javascript/Jquery onclick for the links in the CFGRID.

Thanks for your help!
hefterr
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Grid Links</title>

<!--This is to prevent the grid from being resized-->
<script type="text/javascript">
fixgrid = function() {
   mygrid = ColdFusion.Grid.getGridObject('subscripts')
   cm = mygrid.getColumnModel();

   for(var i=0; i<cm.getColumnCount();i++) {
      col = cm.getColumnById(i)
      col.resizable=false
   }
   
   mygrid.reconfigure(mygrid.getDataSource(),cm);
}
</script>


<style type="text/css">
<!--

/*This controls the alignment of the cells as CFGRID has quirks*/
.x-grid-cell-text {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #666666;
}
.x-grid-hd-text {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #666666;
	text-align: center;
}
.x-grid-col-5 {
    text-align: left;
}
.x-grid-col-4 {
    text-align: left;
}
.x-grid-col-3 {
    text-align: left;
}

.x-grid-col-2 {
    text-align: left;
}

.x-grid-col-1 {
    text-align: left;
}

.x-grid-col-0 {
    text-align: left;
}

/*This allows wrap a round within a cell*/
#Ohist
.x-grid-row td {white-space:normal;}


-->
</style>
</head>

<body>
<cfset ajaxOnLoad("fixgrid")>

<cfform name="OrderHistory" id="Ohist" action="AMsubscript.cfm" method="post"> 
<br />
<br />
 <table width="952" align="center" border="0" cellpadding="0" cellspacing="0">
   
     <tr>
       <td class="acLegend">
                     <cfgrid name="subscripts"
                    format="html"
                    autowidth="no"
                    pagesize="10"
                    striperows="yes"
                    fontsize="12px"
                    textcolor="##666666"
                    selectmode="browse"                    
                    colheadertextcolor="##666666"
                    colheaderfontsize="12px"
                    colheaderbold="yes"
                    colheaderalign="center"
                    selectonload="false"
                    bind="cfc:Test_Mycfc.subscriptions({cfgridpage},
                                            {cfgridpagesize},
                                            {cfgridsortcolumn},
                                            {cfgridsortdirection}
                                             )">
                       
                       <cfgridcolumn name="OrderId"
                                     header="Subscriptions"
                                     dataalign="center"
                                     width="300">
                       <cfgridcolumn name="Odate"
                                     header="Start Date"
                                     dataalign="center"
                                     width="85">              
                       <cfgridcolumn name="Odate"
                                     header="End Date"
                                     dataalign="center"
                                     width="85">
                       <cfgridcolumn name="Period"
                                     header="Payment Terms"
                                     width="100"> 
                       <cfgridcolumn name="Renew"
                                     header="Renew"
                                     href="AMsearchAction.cfm"
                                     hrefkey="OrderId"
                                     width="100"> 
                       <cfgridcolumn name="Cancel"
                                     header="Cancel"
                                     href="AMsearchAction.cfm"
                                     hrefkey="OrderId"
                                     width="100">                             
                                                   
            </cfgrid>
               
       </td>
     </tr>  
   

</cfform>    
</body>

</html>

Open in new window

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
hefterrAuthor Commented:
Hi leakim971,
Here is the cfc associated with the CFGRID:

hefterr
<cfcomponent>


<!--- Browse Subscription History for CFGRID --->
 <cffunction name="subscriptions"
             access="remote"
             returntype="struct"
             hint="Browse method for Ajax grid">
   <cfargument name="page"
               type="numeric"
               required="yes">
   <cfargument name="pageSize"
               type="numeric"
               required="yes">
   <cfargument name="gridsortcolumn"
               type="string"
               required="no"
               default="">
   <cfargument name="gridsortdir"
               type="string"
               required="no"
               default="">
                         

   <!--- Local variables --->
   <cfset var getOrderHist ="">

   <cfquery name="getOrderHist" datasource="#application.dsn#">
     Select  convert(varchar, OrderDate, 106) as ODate,
      'American Corporate Statistical Library. Spencers Greatest Ideas - Volume 1 (autographed copy)' as OrderId,
      ItemsOrdered,
      '$' + Convert(Varchar, Convert(Money,TotalDue),1)  as Total,
      'Click Here' as Renew,
      'Click Here' as Cancel,
      'Quarterly' as Period from Orders
       where Custno = 1000
       and Status  = 2
             
    
	<cfif ARGUMENTS.gridsortcolumn NEQ ""
         and ARGUMENTS.gridsortdir NEQ "">
      ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir#
    </cfif>
   </cfquery>

   <!--- And return it as a grid structure --->
   <cfreturn QueryConvertForGrid(getOrderHist,
                                 ARGUMENTS.page,
                                 ARGUMENTS.pageSize)>
 </cffunction>


</cfcomponent>

Open in new window

0
 
reitersCommented:
You will need to take the href out of the cfgridcolumn to let the link come through for this.
0
 
hefterrAuthor Commented:
Hi reiters,
It looks good!  I didn't realize you could return in a query HTML (anchor link).  I think I could have had this in the original SQL instead of creating a 2nd query (is that correct?).

Thanks,
hefterr
0
 
reitersCommented:
Possibly.  The one I sent was meant for versatility.  You can apply other logic to determine the link location etc.  To the query it's just text but once its ajaxed into the grid, the browser sees it as html.

Glad I could help.
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.