0
votes

My controller returns results in a Array like this:

 render (template: 'show' , model: [changes: changes])

Show is a default action and changes is an Array created with a query(createCriteria). How can I make pagination in my index.gsp page which is displaying results in a HTMl div?

My problem:

Controller:

def list() {
        [terminHistorie: changes, terminHistorieCount: changes.size()]
    }

gsp:

<g:paginate controller="terminHistorie" action="list" total="${terminHistorieCount}"/>

Error: Tag [paginate] is missing required attribute [total] at C:/Users/matejb/Documents/NetBeansProjects/gutmann/grails-app/views/terminHistorie/index.gsp:309

1

1 Answers

2
votes

The way pagination works is you first need to create a view using paginate tag, then on your show action you need to slice your changes. Meaning that the view will send the offset and max parameter and your createCriteria will query the database only for those data. Take a look at this page and then here to see how you can pass max and offset into your createCriteria method.

To see an example, see this page or create a new application with one simple domain and generate scaffolding for it. Grails will generate a paginated result for you.

Btw, if you are using ajax you might want to use remote paginate plugin.