Joshua, Thanks for using my Pagination library! Sorry it's not acting exactly as you had hoped. Your issue looks similar to a feature request posted recently, requesting a setFixedMaximumNumbersShown option but with some sort of bouncy counting and some elasticity somewhat like Amazon's pagination, but as you noticed, it only grows as you page through your records. You can fix this yourself, but you will have to stretch your limits of CFC use a bit.
The solution is to create a component (let's call it bouncyPagination.cfc
) that extends my component, Pagination.cfc
. You will need to override at least one method to accomplish your task. You can read the documentation on Extending Pagination.cfc first, it may help. Your code will look something like this.
<cfcomponent extends="Pagination">
<cffunction name="renderNumericLinksHTML">
<!--- Your improved bouncy numeric links HTML generation here --->
<!--- Start by copying & pasting code from the matching --->
<!--- renderNumericLinksHTML method in Pagination.cfc --->
</cffunction>
</cfcomponent>
Take a look at the code in Pagination.cfc
, in the renderNumericLinksHTML function. Start yourself off by copying and pasting, then rewrite the way BouncyPagination.cfc
writes those numeric links based on whatever logic you want. You can even add some methods to get and set the boundaries of your numbers, in your example, 4
was the magic number. I would imagine you would add something like this to your component.
<!--- Set your new parameter's default by overriding the init method --->
<cffunction name="init">
<cfset variables.my.BouncyBounds = 4 />
<return super.init() />
</cffunction>
<!--- Create getter/setter. Note the rendered=false is a flag to force HTML recomposition when a UI option changes. --->
<cffunction name="getBouncyBounds">
<cfreturn variables.my.bouncyBounds />
</cffunction>
<cffunction name="setBouncyBounds">
<cfargument name="_BouncyBounds" type="string" />
<cfset variables.my.BouncyBounds = arguments._BouncyBounds/>
<cfset variables.my.rendered = false />
</cffunction>
Your new renderNumericLinksHTML
method would call getBouncyBounds()
to programmatically change the boundaries of your newer bouncy pagination method.
I hope that helps you -- this is as far as I go without doing your homework for you. If you write something that works well for you, and you can share with a BSD license, send me the code and I will include it in the next release.