Home

amitjain1982 edited this page Mar 8, 2012 · 2 revisions
Clone this wiki locally

Installation

Just execute following from your application directory:

grails install-plugin remote-pagination

Using

If you have used paginate and sortableColumn tag, then you will find its usage very similar to them. The tags needs to reside inside the template, which renders the list of records.

##Tags
The remote-pagination plugin currently provides the following tags:
1. remotePaginate
2. remoteSortableColumn
3. remotePageScroll


util:remotePaginate

Purpose
Creates next/previous buttons and a breadcrumb trail to allow pagination of results, without a page refresh using ajax calls.

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

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). Provide Map instead of list to display text other than pageSize in a select box.
  • alwaysShowPageSizes(optional) - A boolean value, either to show pageSizes select box irrespective of total records (defaults to false). Use only when pageSizes list or map is provided.

Events

  • onSuccess (optional) - The javascript function to call if successful
  • onFailure (optional) - The javascript function to call if the call failed
  • on_ERROR_CODE (optional) - The javascript function to call to handle specified error codes (eg on404="alert('not found!')"). With Prototype, this prevents execution of onSuccess and onFailure.
  • onUninitialized (optional) - The javascript function to call the a ajax engine failed to initialise
  • onLoading (optional) - The javascript function to call when the remote function is loading the response
  • onLoaded (optional) - The javascript function to call when the remote function is completed loading the response
  • onComplete (optional) - The javascript function to call when the remote function is complete, including any updates

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. For ex. To set max number of records displayed as params="[max: 10]"
  • 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

Events

  • onSuccess (optional) - The javascript function to call if successful
  • onFailure (optional) - The javascript function to call if the call failed
  • on_ERROR_CODE (optional) - The javascript function to call to handle specified error codes (eg on404="alert('not found!')"). With Prototype, this prevents execution of onSuccess and onFailure.
  • onUninitialized (optional) - The javascript function to call the a ajax engine failed to initialise
  • onLoading (optional) - The javascript function to call when the remote function is loading the response
  • onLoaded (optional) - The javascript function to call when the remote function is completed loading the response
  • onComplete (optional) - The javascript function to call when the remote function is complete, including any updates

util:remotePageScroll

Purpose

Renders more records lazily on a click of link, appends them to the existing list of records without a page refresh using ajax calls. This tag needs to be inside a template for example "_listTemplate.gsp".

**Note : This tag is supported only if application's grails javascript library is set to 'jQuery'. **

Examples

<util:remotePageScroll action="filter" total="${total}" update="listTemplateDivId"/>
<util:remotePageScroll action="filter" total="${total}" update="listTemplateDivId" title="Show More Records..." max="5" class="anyCSSClass"/>

Description

Attributes update, action and total are required. This should reside in a template, which loop through the records to be displayed iteratively.

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
  • title (optional) - The text to display for the link (defaults to "Show more...", precedence is given to 'paginate.more.title' property if found in I18n messages.properties).
  • max (optional) - The number of records displayed per page (defaults to 10). Used ONLY if params.max is empty
  • offset (optional) - Used ONLY if params.offset is empty

Events

  • onSuccess (optional) - The javascript function to call if successful
  • onFailure (optional) - The javascript function to call if the call failed
  • on_ERROR_CODE (optional) - The javascript function to call to handle specified error codes (eg on404="alert('not found!')"). With Prototype, this prevents execution of onSuccess and onFailure.
  • onUninitialized (optional) - The javascript function to call the a ajax engine failed to initialise
  • onLoading (optional) - The javascript function to call when the remote function is loading the response
  • onLoaded (optional) - The javascript function to call when the remote function is completed loading the response
  • onComplete (optional) - The javascript function to call when the remote function is complete, including any updates

If you face any problem while installing the plugin, you may download it from here

Version History

  • 0.3 :- Added remotePageScroll tag, In remotePaginateTag, pageSizes now accept both Map & List and also added new option alwaysShowPageSizes.
  • 0.2.8 :- Fixed jira issue
  • 0.2.7 :- Fixed two jira issues i.e bug and improvement

Roadmap

Issues and improvements for this plugin are maintained here on Codehaus JIRA.