• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFCs Returning Query with Bind from CFGrid

Engaged ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

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!

TOPICS
Advanced techniques

Views

842

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

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)>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 11, 2009 May 11, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 11, 2009 May 11, 2009

Copy link to clipboard

Copied

LATEST

<cfset event_info = createObject("component","pip_info")>
<cfset x = event_info.getStart(my_grid.dealer_id)>

Results in "dealer_id is undefined in my_grid" before the page even loads.  It's trying to call that function before I click on anything, which is why I think I need help with the binding.

<cfinvoke component="pip_info" method="getStart">
    <cfinvokeargument name="dealer_id" value="my_grid.dealer_id">
</cfinvoke>

Results in "DEALER_ID argument passed to the getStart function is not of type numeric" even though I haven't clicked any row yet.

CFDEBUG shows that "this.container" is null or not an object for both methods, which makes me think even more that the page is trying to pass something that hasn't been defined yet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation