Tuesday, December 30, 2008

Proper fix for cfgrid having empty rows and wrong information on last page

<cfset startRow = ((page-1) * pageSize) + 1 />
<cfset endRow = startRow + pageSize - 1 />
<cfset tmpQuery = queryNew(get_query.columnList) />
<cfloop query="get_query" startRow="#startRow#" endRow="#endRow#">
<cfset tmp = queryAddRow(tmpQuery) />
<cfloop list="#get_query.columnList#" index="column">
<cfset tmp = querySetCell(tmpQuery,column,evaluate("get_query.#column#")) />
</cfloop>
</cfloop>
<cfset gridQuery = structNew() />
<cfset gridQuery.query = tmpQuery />
<cfset gridQuery.totalrowcount = get_query.recordcount />
<cfreturn gridQuery />




big thanks to Paul

Your comments Here! Hover Your cursor to leave a comment.