Skip to main content
Inspiring
May 8, 2009
Question

CFCs Returning Query with Bind from CFGrid

  • May 8, 2009
  • 1 reply
  • 951 views

I have a cfgrid:

<cfgrid format="html" name="my_grid" query="pip_dealers" height="600" striperows="yes" width="80%" striperowcolor="DDF0FF" >
    <cfgridcolumn name="dealer_id" display="no">
    <cfgridcolumn name="pa_code" header="P&A Code">
    <cfgridcolumn name="dealership_name" header="Dealer">

</cfgrid>

and I'm trying to display in a table on the same page different events associated with each dealer, and these events will show up when a dealer is clicked on.  I'm trying to call a CFC and pass in the dealer_id, get a query back, then loop through the pertinent information with that query.  I'm stumbling on how to bind things not in an input box, and I'm pretty sure I'm confused elsewhere as well.

My function:

<cffunction name="getStart" access="remote" returntype="query">
  <cfargument name="dealer_id" type="numeric" required="yes">
  <cfquery name="get_date" datasource="#app.dsn#">
   SELECT event_begin_date
   FROM  events
   WHERE dealer_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#dealer_id#">
   AND  event_begin_date is not null
  </cfquery>
  <cfset myResult = get_date>
  <cfreturn myResult>
</cffunction>

How do I just call a CFC function?  I don't think this is it:

<cfset x = pip_info.getStart({pip_grid.dealer_id})>

Thanks!

This topic has been closed for replies.

1 reply

ilssac
Inspiring
May 8, 2009

kodemonki wrote:

How do I just call a CFC function?  I don't think this is it:

<cfset x = pip_info.getStart({pip_grid.dealer_id})>

Actually that would work just fine, just as long as you had previously defined 'pip_info' as an instance of your CFC component with either a createObject() function or a <cfinvoke...> tag.  Without the extra curly brackets... I think that is a carry over from other languages syntax.

I.E.  This is perfectly common CFML code"

<cfset pip_info = createObject('component','path.to.a.cfc.file')>

<!--- remmeber not to include the '.cfc' part of the component file name --->

<cfset x = pip_info(pip_grid_dealer_id)>

kodemonkiAuthor
Inspiring
May 11, 2009

Don't I need the curly brackets as I'm trying to bind to the dealer that's been clicked on?  When I took the brackets out, it says that the required argument (dealer_id) was not passed in.  I don't think I'm binding right.