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

cfgrid

Guest
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

Hi,

i have the search page and want to display the results on the the cfgrid.  Both form and cfgrid are on the same page.  When i first open the form.cfm page, i see all the results already display on the page.  This is not right, i only want the results to display when i search something and hit on the submit button.  Can you please help?

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

<cfparam name="variables.row_per_page_default" default="50">

<cfparam name="variables.row_per_page_list" default="15,30,50,75,100">


<cfform name="search" action="form.cfm" method="post" onsubmit ="ColdFusion.Grid.refresh('myGrid', false);">
<cfinput type="text" name="aNo_var" id="aNo_var">
<input class="button" type="submit" name="submit" value="Search" />

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


    <cfgrid
     format="html"
        name="grid01"
        width="700"
        sort=true
          bindOnLoad="true" 
      pagesize="#variables.row_per_page_default#"
         bind="cfc:cfc.searchA.cf_city({cfgridpage},{cfgridpagesize},
            {cfgridsortcolumn},{cfgridsortdirection},
            {aNo_var})">
        <cfgridcolumn name="aNo_var" width="100" display=true header="Name" />
      
    </cfgrid>

</cfform>

<!--cfc--->

<cfcomponent displayname="searchA" output="no" hint="search a number">


<cffunction name ="SearchANo" 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="aNo_var" required="true" type="string" />

<cfset var myQuery = querynew("")>   

<cfquery name="myQuery" datasource="#dsn#">
       select * from mytbl

     where 1=1    
       <cfif arguments.aNo_var neq "">
        aNo_var = <cfqueryparam value="#arguments.aNo_var#" cfsqltype="cf_sql_varchar" maxlength="50" />
  </cfif>
        </cfquery>
<cfreturn queryconvertforgrid(myQuery, page, pagesize) />
</cffunction>
</cfcomponent>

Views

561

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
Explorer ,
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

<cfif isDefined("form.submit")>

<cfgrid>

</cfif>

Ken

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
Guest
Dec 11, 2013 Dec 11, 2013

Copy link to clipboard

Copied

LATEST

thank you

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