History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-1360
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Maurice Nicholson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Grails

g:paginate tag should have option to output current page if only one

Created: 09/Jul/07 04:09 AM   Updated: 20/Sep/07 10:06 AM
Component/s: TagLib
Affects Version/s: 0.5.6
Fix Version/s: 1.1

Time Tracking:
Not Specified


 Description  « Hide
If you use the g:paginate tag and there is only one page it outputs nothing. This makes sense because there is no pagination to render.

But typically your page would still have a pagination section, even if there is only one page.

So you have to add a (cut and pasted) calculation of the number of pages AND an if/else, AND a span mimicking the current page in the real paginate tag output (to benefit from your existing CSS):

Page:
    <g:set var="totalPages" value="${Math.ceil(searchResult.total / searchResult.max)}" />
    <g:if test="${totalPages == 1}"><span class="currentStep">1</span></g:if>
    <g:else><g:paginate controller="searchable" action="index" 
                        params="[q: params.q]" total="${searchResult.total}"
                        prev="&lt; previous" next="next &gt;"/></g:else>

This violates DRY in a number of ways.

So the tag should have an optional "renderSinglePage=true|false" attribute, or similar, so the above code becomes

Page:
    <g:paginate controller="searchable" action="index" 
                params="[q: params.q]" total="${searchResult.total}"
                prev="&lt; previous" next="next &gt;" renderSinglePage="true" />


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.