Passing parameter to CFC while using CFGRID bind

Copy link to clipboard
Copied
I started with the example at http://www.garyrgilbert.com/blog/ind...sion-8s-CFGRID
I'd like to pass one or more variables to filter down the result set.
Copy link to clipboard
Copied
> I am attempting to use CFGRID to display some data. I have a CFGRID set up
> using a bind to a CFC which is fine for a hard coded SQL but I want to pass a
> parameter.
>
> I started with the example at
> http://www.garyrgilbert.com/blog/ind...sion-8s-CFGRID
>
> I'd like to pass one or more variables to filter down the result set.
>
so what's the problem?
how are trying to pass your extra arguments?
this works:
bind="cfc:path.to.cfc.method({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},xtraarg1_number,{formname:controlname@eventname},'xtraarg2_string')"
as long as you have a <cfargument ...> in your cfc method for each of
the extra arguments you supply and they are in the correct order...
--
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Copy link to clipboard
Copied
hi there, did you get this to work? I'm experiencing the same problem. i'd like to bind and pass the CFGRIDKEY to my CFC to filter my query results and then pass back the new results to my cfgrid. at this point i have no problem passing my new parameters as an argument in the json string or as a url paramenter when calling my CFC directly. however, my CFGRID keeps wigging out because it can't see the URL.CFGRIDKEY coming in. thoughts?
here's the process, page load with all users assigned to all classes in my CFGRID. user then clicks on a class number in the grid or selects a class number for a drop down selection form, to view all students assigned to a particular class.
as mentioned above, I can actually get the results i need when calling my CFC directly: http://127.0.0.1:8500/DREST_Pro/admin/getUsers.cfc?method=SPActiveUsers&returnFormat=json&argumentCo...
and i can do this either by adding the cfgridkey argument into the argumentCollection or i can filter my results by appending the cfgridkey as a URL param.
the problem seems to be in my binding of a new parameter when building my cfrid:
<cfform name="getUsers">
<cfgrid format="html" name="displayUsersActive" appendkey="yes" hrefkey="intfkclassid" href="allEnrolled.cfm" selectmode="row" striperows="yes" pagesize="10" bind="cfc:getUsers.SPActiveUsers({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{cfgridkey})" width="650" height="400">
<cfgridcolumn name="intfkclassid" display="no">
<cfgridcolumn name="txtLName" header="Last Name" headerbold="yes" width="20">
<cfgridcolumn name="txtFName" header="First Name" headerbold="yes">
<cfgridcolumn name="startdate" header="Start Date" width="30" headerbold="yes">
<cfgridcolumn name="enddate" header="End Date" headerbold="yes">
<cfgridcolumn name="classno" header="Class No" headerbold="yes">
</cfgrid>
</cfform>
Copy link to clipboard
Copied
Never mind...got it figured out: <cfgrid format="html" name="displayUsersActive" autowidth="yes" selectmode="row" striperows="yes" pagesize="10" bind="cfc:getUsers.SPActiveUsers({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},#url.CFGRIDKEY#)" width="650" height="400">
Just need to remove the {}'s from argument and simply write the value to the bind argumentCollection. Hopefully this will save someone else some time troubleshooting.

Copy link to clipboard
Copied
please help!!!
passing parameters to cfc using the cfgridbind...
im using the cfc bind if u hard coded the query in the cfc its works but if u need to pass a parameters in cfc bind its not working...
for example...
my url with parameter is http://localhost/index.cfm?empid=123&start_date=2009/05/01
<cfform>
<cfajaxproxy bind="javascript:todetail({maingrid.id@change},{maingrid.firstname@none},{maingrid.lastname@none})" />
<cfgrid format="html"
name="maingrid"
bind="cfc:#request.cfcpath#users.getGridas({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
preservepageonsort="true"
appendkey="no"
selectonload="false"
width="750"
style="clear:both;" colheaderalign="center"
>
<cfgridcolumn name="id" display="no" />
<cfgridcolumn name="datatime" header="DATE" width="100"/>
</cfgrid>
</cfform>
my query in cfc file:
select * from hrd_emp
WHERE 0=0
<cfif arguments.id NEQ "">AND (id='#arguments.id#')</cfif>
<cfif arguments.whereClause NEQ "">AND (#preserveSingleQuotes(arguments.whereClause)#)</cfif>
AND (EmpNo = '#######') =====> i need to put the empid=123 from the url http://localhost/index.cfm?empid=123&start_date=2009/05/01
PLEASE HELP!!!

Copy link to clipboard
Copied
I'm getting into this conversation at a very late date, but I thought I could help some other poor soul that had problems passing additional arguments to a cfc using the bind string in a cfgrid (or other CF8 ajax control).
I had some additional search terms that I had put into a preconstructed string WHERE clause. When I added this string to the bind argument, I would get errors similar to "You cannot pass anonymous and positional arguments at the same time." Nowhere did I see any discussion of how to build the bind string, but I did follow some other examples similar to Dan's - mine didn't work.
After futzing for too many hours, I wondered if maybe the string couldn't contain blanks, even though it was within embedded quotes. Then a light-bulb popped and I said: This must be like a URL! Voila, pass any string through a URLEncode() and it works fine. (URLDecode in the CFC.)

