Change count of displaing items in paginate sectio

2019-07-21 05:10发布

问题:

Is there any way to change count of displaying beans into paginate section by user in grails 2x? I can not find this in grails docs. It means something like (see itemsPerPage)

<g:paginate total="${beanInstanceTotal}" itemsPerPage="[10,20,50]" .../>

I think that this is obvious functionality for pagination.

回答1:

Check the max parameter in g:paginate.

From the docs:
max (optional) - The number of records to display per page (defaults to 10). Used ONLY if params.max is empty

You can then parse params.max in the controller and pass it to the query.

EDIT:
I'm sorry, I misunderstood your question. The combo box you described is not available in the default <g:paginate> tag. I had this same issue in my application and implemented the select item with the awesome Remote Pagination plugin. Usage is described in the docs.

<util:remotePaginate controller="book" action="filter" total="${Book.count()}" update="listTemplateDivId"
              max="20" pageSizes="[10:'10 Per Page', 20: '20 Per Page', 50:'50 Per Page',100:'100 Per Page']"/>