Solved

CFGRID : POP UP Via Link?

Posted on 2010-09-16
7
695 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
  • 3
  • 3
7 Comments
 
LVL 82

Expert Comment

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

Author Comment

by:hefterr
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Accepted Solution

by:
reiters earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now