The Dopefly Tech Blog

<< The Dopefly Tech Blog Main page

Pagination 1.0 Released

posted under category: Free Code For You on September 23, 2008 at 1:00 am by MrNate

So after nearly a year of sitting on Pagination 1.0 RC, I finally have the 1.0 release of the data paging library for ColdFusion.

The only thing in the 1.0 final version that I changed from the release candidate was the error messages. Most of the questions I had were about why they were getting a variable doesn't exist type error. Turns out they didn't call init() or didn't set the queryToPaginate item. I added some checking and some cfthrows to better explain what is happening.

Pagination.cfc is available to download at RIAForge, and the subversion repository has all the files as well.

Too old to comment!
On Sep 21, 2011 at 1:00 AM Fred (feras1973@aol.com or @gmail.com) said:
How do I deal with grouping my results? I have nested cfoutputs and I am not getting the proper output.

<cfoutput query="getTitles" startrow="#pagination.getStartRow()#" maxrows="#pagination.getMaxRows()#" group="SubsectionName">
<tr>
<td>#getTitles.subsectionname</td>
</tr>

<table>
<cfoutput>
<tr>
<td #bookIDStyle#>#getTitles.BookID#</td>
</tr>
</cfoutput>
</cfoutput>
</table>

On Sep 23, 2011 at 1:00 AM Nathan Strutz (www.dopefly.com) said:
Fred, I see your problem, but I can't think of an immediate way to do what you want. There are, however, a lot of ways to go that aren't easy.

I think you should maybe extend the pagination.cfc object and make one that works for grouped output. I can't think of a straightforward way to do it, since this code has been out of my head for a couple years now. You can catch an example of extending it on the documentation: http://www.dopefly.com/projects/pagination/pagination_cfc_documentation.cfm#Section6

Most likely, the solution will be to add a property for grouping, then overwrite getTotalNumberOfPages, getStartRow, getEndRow and getRenderedHTML. That's just from my first glance, so you may not actually have to do all of those, but then I may have missed a couple. Honestly it probably won't be too hard for you, just start with what's there, copy & paste those methods into an extending component, then tweak them for grouped output.

One more thing, if you do something cool, if you get it to work, can you submit it back to the project so we can add it to the source code and share your success with others? Not required or anything, but I'd appreciate the help, and so would hundreds of other developers who use Pagination.cfc. Thanks!

On Apr 10, 2013 at 1:00 AM Brad (bullarni has underestimated gmail.com) said:
Hi Fred this reply is way to late to assist you but a possible solution for anyone else who stumbles across this is page is to use un-nested cfoutput tags and to handle the grouping yourself. This is how most non-coldfusioners typically have to query grouping.

So for your example above you would need to do something like the following:

<cfset lastSubSectionName = "">
<cfoutput query="getTitles" startrow="#pagination.getStartRow()#" maxrows="#pagination.getMaxRows()#">
<cfif lastSubSectionName neq getTitles.subsectionname>
<tr>
<td>#getTitles.subsectionname</td>
</tr>
<table>
</cfif>
<tr>
<td #bookIDStyle#>#getTitles.BookID#</td>
</tr>
<cfset lastSubSectionName = getTitles.subsectionname>
</cfoutput>
</table>
Too old to comment!