views:

189

answers:

1

Hi, I have an application written in groovy and I am having problems with the pagination of a resulting set.

I have a Controller called ReportingController. This controller has two methods called listdoiTln and listdoiEv. Both methods are similar and at the end both have to render a list of reports. The last lines of both are as follows:

params.max = Math.min(params.max ? params.max.toInteger() : 15,  100)             
render (view: 'list', model:[reportingInstanceList: reportingInstanceList, reportingInstanceTotal: i])

The list view is rendered as expected. At the footer of the list.gsp file I have:

<div class="paginateButtons">
    <g:paginate controller="reporting" total="${reportingInstanceTotal}" max="25"/></div>
</div>

The list is working, the buttons for the pagination are there but it is always displayed the whole collection. Notice that I do not have files callled listdoiTln.gsp or listdoiEv.gsp. I am using list.gsp with different data models.

Surely I am doing something wrong.

Any hint?

Thanks in advance.

Luis

+1  A: 

I had trouble with this, too, for quite a while. Try this:

Evaluate param.offset in the controller:

params.offset = params?.offset?.toInteger() ?: 0

Include the params in the model:

render (view: 'list', model:[reportingInstanceList: reportingInstanceList, reportingInstanceTotal: i, params: params])

Check whether the value of reportingInstanceTotal is the value that you expect. That tripped me up for a while.

If it still doesn't work, let me know, or try looking at one of the list.gsp pages and its associated controller that are generated by the grails generate-all command.

The paginate buttons are quite cool, but there is little documentation and it takes longer than I expected to set them up.

John Kinzie
Thanks for you comment. Unfortunately it doesn't make any difference.
Luixv
Sorry about that. I went back to my code to figure out what else should be done and added new instructions to my answer. Let me know if it still doesn't work.
John Kinzie
Thanks again for your comment. Unfortunately it didn't help. The whole list is displyed. I've added -as debuggin- following lines at the list.gsp: ${reportingInstanceTotal} - ${max} - ${params.offset}. The buttons are displayed but the whole list is there. Also at every column the links for sorting don't work. (+1) for your help.
Luixv
I'll keep looking for a reason the whole list keeps appearing. For the column sorting links, there isn't room in a comment to explain how I got them to work. If you create a question I can post the code. Thanks for the +1.
John Kinzie
ok, I am opening a new question.
Luixv