Remote-Pagination plugin provides tags for pagination and to sort columns without page refresh using ajax and loads only the list of objects needed. It supports multiple paginations as well. More than one remotePaginate and remoteSortableColumn can be used.
Installation
Just execute following from your application directory:
grails install-plugin remote-pagination
Prerequisites
- Prototype javascript framework included.
Using
If you have used paginate and sortableColumn tag, then you will find its usage very similar to them.
Tags
The remote-pagination plugin currently provides the following tags:
util:remotePaginate
Purpose
Creates next/previous buttons and a breadcrumb trail to allow pagination of results, without a page refresh using ajax calls.
Example domain class
class Book {
String title
String author
}Example controller:
class BookController {
def list = {
[books: Book.list(params)]
} def updateList ={
render(template:"listTemplate" ,model:[ bookInstanceList: Book.list(params )])
}
}remotePaginate code:
<util:remotePaginate controller="book" action="updateList" total="${Book.count()}"
update="listTemplateDivId" max="20" pageSizes="[10, 20, 50,100]"/>Description
Attributes
- total (required) - The total number of results to paginate
- action (required) - the name of the action to use in the link
- update (required) – the id of the div/span which contains the tag to render the template, which displays the list.
- 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 containing request parameters
- prev (optional) - The text to display for the previous link (defaults to "Previous" as defined by default.paginate.prev property in I18n messages.properties)
- next (optional) - The text to display for the next link (defaults to "Next" as defined by default.paginate.next property in I18n messages.properties)
- max (optional) - The number of records displayed 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
- pageSizes(optional) - The list containing different page sizes user can select from(defaults to max attribute or the first value given in the list)
util:remoteSortableColumn
Purpose
Renders a remote sortable column to support sorting in tables , without a page refresh using ajax calls.
Examples
<util:remoteSortableColumn property="title" title="Title" update="listTemplateDivId"/>
<util:remoteSortableColumn property="title" title="Title" style="width: 200px" update="listTemplateDivId"/>
<util:remoteSortableColumn property="author" defaultOrder="desc" title="author"
titleKey="book.author" update="listTemplateDivId"/>Description
Attributes update, action and either title or titleKey are required. When title or titleKey attributes are specified then titleKey takes precedence, resulting in the title caption to be resolved against the message source. In case when the message could not be resolved, the title will be used as title caption.
Attributes
- property - name of the property relating to the field
- defaultOrder (optional) - default order for the property; choose between asc (default if not provided) and desc
- title (optional) - title caption for the column
- titleKey (optional) - title key to use for the column, resolved against the message source
- params (optional) - a map containing request parameters
- action (required) - the name of the action to use in the link
- update (required) – the id of the div/span which contains the tag to render the template, which displays the list.
- controller (optional) - the name of the controller to use in the link, if not specified the current controller will be linked
If you face any problem while installing the plugin, you may download it from
hereRoadmap
Issues and improvements for this plugin are
maintained here on Codehaus JIRA.