• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

CFGrid Help

I need help creating a link inside a CFGrid.  Below is my code.  The problem is the output the code is generating.

The ouput:
http://mymobisaver.com/detailcoupon.cfm?CFGRIDKEY=38,Tammy's%20Oasis%20inside%20Cuttin'%20It%20Up!,25%25%20off%20%0D%0AHis%20&%20Hers%20Fragrances%20,Cuyahoga%20Falls,02-09-12

All I want the link to contain is:
http://mymobisaver.com/detailcoupon.cfm?CFGRIDKEY=38

Below is my Code:
<cfform name="CouponForm" format="html">
              <cfgrid name="parkGrid" selectmode="row" format="html" pagesize="8" width="580" bind="cfc:listCoups.getParks({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
                <cfgridcolumn name="Cid" header="id" display="no">
                <cfgridcolumn name="businessName" width="200" textcolor="Blue" header="Business Name" href="detailcoupon.cfm" hrefkey="id"/>
                <cfgridcolumn name="cDescription" width="200" header="Coupon" href="detailcoupon.cfm" hrefkey="id" />
                <cfgridcolumn name="city" width="110" header="City" href="detailcoupon.cfm" hrefkey="id" />
                <cfgridcolumn name="NEWexpDate" width="70" header="Exp Date" href="detailcoupon.cfm" hrefkey="id" />
              </cfgrid>
            </cfform>

Open in new window

0
sonicimpulse
Asked:
sonicimpulse
  • 7
  • 6
  • 4
1 Solution
 
RickEpnetCommented:
I think we need to take a look at your CFC and the query in it. Do you ahve any idea why your ID field is giving you all the extra information.

38 is all you want but it is givings you all this extra.

38,Tammy's Oasis inside Cuttin' It Up!,25% off His

Myself I normally only have one column with a hrefkey="id"

0
 
sonicimpulseAuthor Commented:
Here is the code in my CFC:
<cffunction name="restaurants" access="remote" returntype="struct">
	<cfargument name="page" required="true" />
	<cfargument name="pageSize" required="true" />
	<cfargument name="gridsortcolumn" required="true" />
	<cfargument name="gridsortdirection" required="true" />
	
	<cfif arguments.gridsortcolumn eq "">
		<cfset arguments.gridsortcolumn = "businessName" />
		<cfset arguments.gridsortdirection = "asc" />
	</cfif>
    
	<cfset todayDate = Now()>
	<cfquery name="ListCoups" datasource="security">
SELECT  *, DATE_FORMAT(expdate, '%m-%d-%y') AS NewExpDate, coupon.id AS cID
FROM     coupon,member
WHERE  coupon.memberid=member.id and coupon.catagoryid=1 and coupon.expdate>#todayDate#
ORDER BY coupon.expdate asc
	</cfquery>

	<cfreturn queryconvertforgrid(listCoups, page, pagesize) />
</cffunction>

Open in new window

0
 
_agx_Commented:
> Myself I normally only have one column with a hrefkey="id"

What happens if you try Rick's suggestion? ie Only make 1 column a link instead of all of them.

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
RickEpnetCommented:
From your code I can see you must have multiple field with the name ID coupon.id and member.id.

How does the grid know which ID to use? What about if you changed the grid to show the cID like this?

<cfform name="CouponForm" format="html">
              <cfgrid name="parkGrid" selectmode="row" format="html" pagesize="8" width="580" bind="cfc:listCoups.getParks({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
                <cfgridcolumn name="Cid" header="id" display="no">
                <cfgridcolumn name="businessName" width="200" textcolor="Blue" header="Business Name" href="detailcoupon.cfm" hrefkey="cid"/>
                <cfgridcolumn name="cDescription" width="200" header="Coupon" href="detailcoupon.cfm" hrefkey="cid" />
                <cfgridcolumn name="city" width="110" header="City" href="detailcoupon.cfm" hrefkey="cid" />
                <cfgridcolumn name="NEWexpDate" width="70" header="Exp Date" href="detailcoupon.cfm" hrefkey="cid" />
              </cfgrid>
            </cfform>
0
 
_agx_Commented:
> you must have multiple field with the name ID coupon.id and member.id.

Oh, I missed the evil SELECT *.  If that's the real problem, better to modify the underlying SELECT instead to eliminate the ambiguity IMO. Only include the columns you're using in the grid. No reason to return extra data if it's not being used.
0
 
sonicimpulseAuthor Commented:
That does not fix my problem with the HTML link though.  I do agree I should not have the evil SELECT * in my code.  I'm going to get rid of it.
0
 
RickEpnetCommented:
What field(s) is this information coming from?

Tammy's Oasis inside Cuttin' It Up!,25% off His
0
 
sonicimpulseAuthor Commented:
ID
BName
CName
CDisclaimer
Baddress
Bcity
BState
Bzip
EXPDate

0
 
_agx_Commented:
Which one of those columns contains the data values Rick posted?
0
 
sonicimpulseAuthor Commented:
Bname
Cname
0
 
RickEpnetCommented:
So that field is getting into the Variable ID some how. agx do you see how that is happening? I do not see it.
0
 
RickEpnetCommented:
I should say those fields
0
 
sonicimpulseAuthor Commented:
I have an idea for a work around.  I did a cfoutput on the variable to see exactly what it contain and here is the result.

26,Spc Sports,10% off any retail purchase! ,Mentor,12-31-11

Is there away to strip the contents of the string so I only get the first set of numbers?  
Keep everything untill you get to the first comma.
0
 
sonicimpulseAuthor Commented:
I guess I should make that a question.  Leave this open to see if anyone can fix it.
0
 
RickEpnetCommented:
That is not the correct way of doing it. The variable should only contain the number. How is that orher data getting in there? That is why I ask which field that data was in.
0
 
RickEpnetCommented:
If you want to strip it out it is pretty easy to do. When I get back to a computer I can write it out or maybe agx would post it.
0
 
_agx_Commented:
Sorry guys, just got back.

I'm not near a CF install right now but .. since the values are separated by commas you use list functions to grab the first or nth value. But better to figure out why it's happening .. because something seems off.

     ie 26,Spc Sports,10% off any retail purchase! ,Mentor,12-31-11
         <cfset value = listFirst(theVariable, ",")>   <=== first value ie 26
         <cfset value = listGetAt(theVariable, 2, ",")>   <=== second value "Spc Sports"
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 7
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now