(Quick Reference)

paginate

Purpose

Creates next/previous buttons and a breadcrumb trail for pagination of results

Examples

Example domain class:

class Book {
    String title
    String author
}

Example controller:

class BookController {
    def list() {
        [books: Book.list(params), bookCount: Book.count()]
    }
}

Paginate code:

<g:paginate controller="book" action="list" total="${bookCount}" />

or

<g:paginate next="Forward" prev="Back"
            maxsteps="0" controller="book"
            action="list" total="${bookCount}" />

Description

Attributes

  • total (required) - The total number of results to paginate
  • action (optional) - the name of the action to use in the link; if not specified the default action will be linked
  • controller (optional) - the name of the controller to use in the link; if not specified the current controller will be linked
  • id (optional) - The id to use in the link
  • params (optional) - A Map of request parameters
  • prev (optional) - The text to display for the previous link (defaults to "Previous" as defined by default.paginate.prev property in the i18n messages.properties file)
  • next (optional) - The text to display for the next link (defaults to "Next" as defined by default.paginate.next property in the i18n messages.properties file)
  • max (optional) - The number of records to display per page (defaults to 10). Used ONLY if params.max is empty
  • maxsteps (optional) - The number of steps displayed for pagination (defaults to 10). Used ONLY if params.maxsteps is empty
  • offset (optional) - Used ONLY if params.offset is empty

Source