queryConvertForGrid

Converts query data to a structure that contains a paged subset of the query.

queryConvertForGrid(query, page, pageSize) → returns struct

Argument Reference

query string
Required

No Help Available

page numeric
Required

No Help Available

pageSize numeric
Required

No Help Available

Examples
Sample code invoking the queryConvertForGrid function

<!--- cfm page ---> 
 <cfform> 
 <cfgrid format="html" name="grid01" pagesize=5 sort=true bind="cfc:places.getData({cfgridpage},{cfgridpagesize}, {cfgridsortcolumn},{cfgridsortdirection})" selectMode="row"> 
 <cfgridcolumn name="Emp_ID" display=true header="Employee ID"/> 
 <cfgridcolumn name="FirstName" display=true header="Name"/> 
 <cfgridcolumn name="Email" display=true header="Email"/> 
 </cfgrid> 
 </cfform> 
 
 <!--- cfc page ---> 
 <cffunction name="getData" access="remote" output="false"> 
 <cfargument name="page"> 
 <cfargument name="pageSize"> 
 <cfargument name="gridsortcolumn"> 
 <cfargument name="gridstartdirection"> 
 <cfset query = "SELECT Emp_ID, FirstName, EMail 
 FROM Employees" > 
 <cfif gridsortcolumn neq "" or gridstartdirection neq ""> 
 <cfset query=query & " order by #gridsortcolumn# #gridstartdirection#"> 
 </cfif> 
 <cfquery name="team" datasource="cfdocexamples"> 
 <cfoutput>#query#</cfoutput> 
 </cfquery> 
 <cfreturn queryConvertForGrid(team, page, pageSize)> 
 </cffunction>

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub