Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

cfgrid

$
0
0

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>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>