Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFGRID : POP UP Via Link?

Posted on 2010-09-16
7
Medium Priority
?
721 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:hefterr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 33706597
Do you have a simple page with a cfgrid to propose ?
0
 
LVL 1

Author Comment

by:hefterr
ID: 33709042
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
 
LVL 1

Author Comment

by:hefterr
ID: 33709045
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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 
LVL 6

Accepted Solution

by:
reiters earned 2000 total points
ID: 33717717
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
 
LVL 6

Expert Comment

by:reiters
ID: 33717732
You will need to take the href out of the cfgridcolumn to let the link come through for this.
0
 
LVL 1

Author Comment

by:hefterr
ID: 33717869
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
 
LVL 6

Expert Comment

by:reiters
ID: 33717936
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

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
What You Need to Know when Searching for a Webhost Provider
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question