Copy link to clipboard
Copied
I am using a url with a variable tacked on it. When I call a file with to create a cfgrid the cfc it uses gives an error. It tells me the variable is undefined. This is a problem since I need to use it in the sql to create the grid. Seems like this is not the right way to get the variable to the sql statement but I dont know how else to do it since I have to use a url to invoke the grid. Thanks in advance for your help.
Copy link to clipboard
Copied
Maybe it is just Friday ... but I have absolutely no idea what you mean Can you post some code so we can get a better sense of the problem? A small amount to demonstrate the variable / scope issues you mentioned.
Copy link to clipboard
Copied
Here is the cfc. This is called from the cfgrid also shown below.
<!--- cfgrid below -
linking to this file from url with the variable i
need to pass to the cfc- hope this helps >
<cfgrid name="protrainparticipants"
format="html"
pagesize="10"
striperows="yes"
selectmode="edit"
delete="yes"
bind="cfc:participantcomp.getparticipants(,
,
,
)"
onchange="cfc:participantcomp.editparticipant(,
,
)">
<!-</cfwindow>-
Copy link to clipboard
Copied
Well it's Saturday here, and I still can't make head or tail of what they're on about 😉
That said, I've not had any coffee yet...
--
Adam
Copy link to clipboard
Copied
Its probably too basic. I just want to send a url variable to the cfgrid page where the cfc is invoked. The variable is used in the query that will populate the grid. I get an error saying that the cfc cannot be invoked because the url variable is not found or defined. Is it not possible to send a url variable to the cfc and if no how do i get the variable to the query?
Copy link to clipboard
Copied
What's the actual code (CFC method, CFM template with the <cfgrid> on it, and probably the full URL you're calling, too), and what's the actual error.
I dunno if you noticed, but the posting you made before which I think you meant to put your code into is a bit garbled.
--
Adam
Copy link to clipboard
Copied
<cfform>
<cfinput name="testVar" value="#URL.myVar#" type="hidden">
<cfgrid selectmode="edit" bind="cfc:cfgridtest.getCourses({cfgridpage},{cfgridpagesize},
{cfgridsortcolumn},{cfgridsortdirection},{testVar})" name = "courseGrid" format="html" height="320" width="580" onChange="cfc:cfgridtest.editCourses({cfgridaction},{cfgridrow},{cfgridchanged})">
<cfgridcolumn name="Course_ID" display=true header="Course ID"/>
<cfgridcolumn name="Dept_ID" display=true header="Dept ID"/>
<cfgridcolumn name="CorNumber" display=true header="Course Number"/>
<cfgridcolumn name="CorName" display=true header="Course Name"/>
<cfgridcolumn name="CorLevel" display=true header="Course Level"/>
</cfgrid>
</cfform>
Copy link to clipboard
Copied
Thanks for the reply. I added your changes using my variable course_id - i also added it as an argument on in the cfc - now i get the eror can't load a null on the cfgrid page
Copy link to clipboard
Copied
What's the actual code(CFC method, CFM template with the <cfgrid>
on it, and probably the full URL you're calling, too)
As mentioned, you need to post the actual code. The forum software mangled what you posted earlier. Without seeing the code, we can only make guesses.
-Leigh
Copy link to clipboard
Copied
this is link to editable grid
<a href="participantgrid.cfm?course_id=#getresults.procourse_id#">#procourse_course#</a>
<!---participantgrid.cfm --- below--->
<cfform>
<cfinput name="course_ID" value="#url.course_id#" type="hidden">
<cfgrid name="protrainparticipants"
format="html"
pagesize="10"
striperows="yes"
selectmode="edit"
delete="yes"
bind="cfc:participantcomp.getparticipants({cfgridpage},
{cfgridpagesize},
{cfgridsortcolumn},
{cfgridsortdirection}, {course_id})"
onchange="cfc:participantcomp.editparticipant({cfgridaction},
{cfgridrow},
{cfgridchanged})">
<CFGRIDCOLUMN NAME="proparticipant_course_id"
WIDTH=2
DISPLAY="no">
<CFGRIDCOLUMN NAME="proparticipant_id"
HEADER="Paricipant ID"
WIDTH=10
ITALIC="NO"
HEADERALIGN="center"
HEADERITALIC="NO"
HEADERBOLD="YES"
DISPLAY="no">
<CFGRIDCOLUMN NAME="proparticipant_firstname"
HEADER="First Name"
WIDTH=120
ITALIC="NO"
HEADERALIGN="center"
HEADERITALIC="NO"
HEADERBOLD="YES"
DISPLAY="YES"
SELECT="YES">
<CFGRIDCOLUMN NAME="proparticipant_lastname"
HEADER="Last Name"
WIDTH=120
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_p_country"
HEADER="Country"
WIDTH=80
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_email"
HEADER="Email"
WIDTH=160
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_phone"
HEADER="Phone"
WIDTH=100
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_fax"
HEADER="Fax"
WIDTH=100
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_projid"
HEADER="Project ID"
WIDTH=80
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
<CFGRIDCOLUMN NAME="proparticipant_agency"
HEADER="Agency"
WIDTH=80
ITALIC="No"
HEADERALIGN="center"
HEADERITALIC="No"
HEADERBOLD="Yes"
BOLD="Yes"
DISPLAY="Yes">
</cfgrid>
</cfform>
<!---- participantcomp.cfc--below --->
<cfcomponent output="false">
<cfset THIS.dsn="protraining">
<!--- Get participants --->
<cffunction name="getparticipants" access="remote" returntype="struct">
<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="">
<cfargument name="course_id" type="numeric" required="yes" default="#course_id#">
<!--- Local variables --->
<!--- Get data --->
<CFQUERY NAME="Chkcourse2" DATASOURCE=#THIS.dsn#>
SELECT procourse_id, procourse_course
FROM afrreg38.tblProcourse
WHERE procourse_id = #arguments.course_id#
</CFQUERY>
<cfset current_course_id = #chkcourse2.course_id#>
<cfquery name="qrygetparticipants" datasource="#application.dsn#">
select pp.proparticipant_id, pp.proparticipant_course_id, pp.proparticipant_firstname, pp.proparticipant_lastname, pc.procourse_course, pp.proparticipant_p_country, pp.proparticipant_email, pp.proparticipant_phone, pp.proparticipant_fax, pp.proparticipant_projid, pp.proparticipant_agency, pc.procourse_id
FROM afrreg38.tblProparticipant_3 pp, afrreg38.tblProcourse pc, afrreg38.tblproparticipant_course_test_2 pct
WHERE pp.proparticipant_id = pct.proparticipant_participant_id
and pp.proparticipant_course_id = pc.procourse_id
and pc.procourse_id = #variables.current_course_id#
<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(qrygetparticipants,
ARGUMENTS.page,
ARGUMENTS.pageSize)>
</cffunction>
<!--- Edit an artist --->
<cffunction name="editparticipant" access="remote">
<cfargument name="gridaction" type="string" required="yes">
<cfargument name="gridrow" type="struct" required="yes">
<cfargument name="gridchanged" type="struct" required="yes">
<!--- Local variables --->
<cfset var colname="">
<cfset var value="">
<!--- Process gridaction --->
<cfswitch expression="#ARGUMENTS.gridaction#">
<!--- Process updates --->
<cfcase value="U">
<!--- Get column name and value --->
<cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
<cfset value=ARGUMENTS.gridchanged[colname]>
<!--- Perform actual update --->
<CFQUERY name="updateparticipant_data" datasource="#THIS.dsn#">
UPDATE afrreg38.tblProparticipant_3
SET #colname# = '#value#'
WHERE proparticipant_id = #ARGUMENTS.gridrow.proparticipant_id#
</CFQUERY>
<!--- <cfquery datasource="#THIS.dsn#">
UDPATE afrreg38.tblproparticipant_course_test_2
SET #colname# = '#value#'
</cfquery> --->
</cfcase>
<!--- Process deletes --->
<cfcase value="D">
<!--- Perform actual delete --->
<cfquery datasource="#THIS.dsn#">
DELETE FROM afrreg38.tblProparticipant_3
WHERE proparticipant_id = #ARGUMENTS.gridrow.proparticipant_id#
</cfquery>
</cfcase>
</cfswitch>
</cffunction>
</cfcomponent>
Copy link to clipboard
Copied
<cfoutput>
<a href="participantgrid.cfm?course_id=#getresults.procourse_id#">#procourse_course#</a>
</cfoutput>
<!--- differentiate form variable from URL variable --->
<cfinput name="id" value="#url.course_id#" type="hidden">
bind="cfc:participantcomp.getparticipants({cfgridpage},
{cfgridpagesize},
{cfgridsortcolumn},
{cfgridsortdirection}, {id})"
Copy link to clipboard
Copied
Ok. Works. Awesome. Thank you!!!!!!!!!!!!
Copy link to clipboard
Copied
Good. Could you please tell us what the breakthrough was?