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

EnterKey in cfgrid

Explorer ,
Feb 16, 2012 Feb 16, 2012

Copy link to clipboard

Copied

I have the search form with three fields: city, state, and enter date.  The results are displayed in the cfgrid.  Currently, when i enter search criteria, i have to use the tab kep to refresh the data from the cfgird's results.  Instead of using the tab key, i need to use the enter key.  I don't know if i have the correct way but the code i have below didn't work because more arguments from cfgrid than cfc(i have extra the getSearchString () from cfgrid)

can you help with this?

Thanks

-----------------------------

<!---my cfc-->

<cffunction name ="cf_city" access="remote" returnpe="struct">

     <cfargument name ="page" required="true" />

     <cfargument name = "pageSize" required="true" />

     <cfargument name ="gridsortcolumn" required="true" />

     <cfargument name ="gridsortdirection required="true" />

     <cfargument name="city" required="true" type="string" />

     <cfargument name ="state" required="true" type="string" />

     <cfargument name ="date" required="true" type="date" />

</cffunction>

<!---my form.cfm--->

<cfform name="search" action="##" method="post" onsubmit ="ColdFusion.Grid.refresh("myGrid", false);">

<cfinput type="text" name="city" id="city">

<cfinput type="text" name="state" id="state">

<cfinput type="datefield" name="date" id="date">

</cfform>

<!---scrpt function--->

<script>

  getSearchString = function() {

   var s ={};

     s.city=ColdFusion.getElementValue("city");

     s.state=ColdFusion.getElementValue("state");

     s.date= ColdFusion.getElementValue("date");

return s;

</script>

<!---diplay on the cfgrid--->

<cfgrid

     name="myGrid"

     format="HTML"

     title="search result"

     selectMode="Single"

     pagesize= "20"

     bindOnLoad ="true"

    bind = "cfc.myapp.cfc.filter.cfc_city ({cfridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},getSearchString(),{city},{state};{date})">

     <cfgridcolumn name="city" header="city">

     <cfgridcolumn name="state" header="state">

</cfgrid>

thanks

TOPICS
Getting started

Views

1.1K

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
Community Expert ,
Feb 20, 2012 Feb 20, 2012

Copy link to clipboard

Copied

LATEST

kt03 wrote:

I have the search form with three fields: city, state, and enter date.  The results are displayed in the cfgrid.  Currently, when i enter search criteria, i have to use the tab kep to refresh the data from the cfgird's results.  Instead of using the tab key, i need to use the enter key.  I don't know if i have the correct way but the code i have below didn't work because more arguments from cfgrid than cfc(i have extra the getSearchString () from cfgrid)

can you help with this?

Thanks

-----------------------------

<!---my cfc-->

<cffunction name ="cf_city" access="remote" returnpe="struct">

     <cfargument name ="page" required="true" />

     <cfargument name = "pageSize" required="true" />

     <cfargument name ="gridsortcolumn" required="true" />

     <cfargument name ="gridsortdirection required="true" />

     <cfargument name="city" required="true" type="string" />

     <cfargument name ="state" required="true" type="string" />

     <cfargument name ="date" required="true" type="date" />

</cffunction>

Suggestions:

<cfcomponent>

<cffunction name ="cf_city" access="remote" returnpe="struct">

<cfargument name ="page" required="true" />

<cfargument name = "pageSize" required="true" />

<cfargument name ="gridsortcolumn" required="true" />

<cfargument name ="gridsortdirection" required="true" />

<cfargument name="city" required="true" type="string" />

<cfargument name ="state" required="true" type="string" />

<cfargument name ="date" required="true" type="date" />    

<!--- return at least an empty query to avoid errors,  enabling you to test --->

<cfset var myQuery = querynew("")>    

<cfreturn queryconvertforgrid(myQuery, page, pagesize) />

</cffunction>

</cfcomponent>

<!---my form.cfm--->

<cfform name="search" action="##" method="post" onsubmit ="ColdFusion.Grid.refresh("myGrid", false);">

<cfinput type="text" name="city" id="city">

<cfinput type="text" name="state" id="state">

<cfinput type="datefield" name="date" id="date">

</cfform>

<!---scrpt function--->

<script>

  getSearchString = function() {

   var s ={};

     s.city=ColdFusion.getElementValue("city");

     s.state=ColdFusion.getElementValue("state");

     s.date= ColdFusion.getElementValue("date");

return s;

</script>

<!---diplay on the cfgrid--->

<cfgrid

     name="myGrid"

     format="HTML"

     title="search result"

     selectMode="Single"

     pagesize= "20"

     bindOnLoad ="true"

    bind = "cfc.myapp.cfc.filter.cfc_city ({cfridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection },getSearchString(),{city},{state};{date})">

     <cfgridcolumn name="city" header="city">

     <cfgridcolumn name="state" header="state">

</cfgrid>

Suggestions:

1) Place the closing form tag </cfform> after the grid.

2) Give the datefield a default value.

3) Begin the bind expression with "cfc:", not "cfc.".

4) Correct the spelling of the name of the function in the bind. It is "cf_city", not "cfc_city".

5) Remove getSearchString() from the arguments list in the bind.

6) Replace the semicolon in {state};{date} with a comma.

The result should be something like

<cfform name="search" action="##" method="post" onsubmit ="ColdFusion.Grid.refresh('myGrid', false);">

    <cfinput type="text" name="city" id="city">

    <cfinput type="text" name="state" id="state">

    <cfinput type="datefield" name="date" id="date" value="#now()#">

    <cfgrid

         name="myGrid"

         format="HTML"

         title="search result"

         selectMode="Single"

         pagesize= "20"

         bindOnLoad ="true"

         bind = "cfc:myapp.cfc.filter.cf_city({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{city},{state},{date})">

         <cfgridcolumn name="city" header="city">

         <cfgridcolumn name="state" header="state">

    </cfgrid>

</cfform>

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