amitjain1982 / remote-pagination

Apache License 2.0
11 stars 16 forks source link

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. Checkout the Sample Application here.

Config

We can provide default max elements to be displayed for all remote-paginate tags via following configuration. However, it defaults to 10.

//In Config.groovy
grails.plugins.remotepagination.max=20
//EnableBootstrap here when using twitter bootstrap, default is set to false.
grails.plugins.remotepagination.enableBootstrap=true

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 used for  all tags:
  class BookController {
    def list = {
       [books: Book.list(params)]
    }
    def filter ={
      render(template:"listTemplate" ,model:[ bookInstanceList: Book.list(params )])
    }        
  }
  


remotePaginate code written inside _listTemplate.gsp:

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

Description

Attributes update, action and total are required.

Attributes

Events

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

Events

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".
Examples

//This tag is supported only if application's grails javascript library is set to 'jQuery'.
<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

Events

util:remoteNonStopPageScroll

Purpose

Renders more records lazily on page scroll, 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".

Examples

//This tag is supported only if application's grails javascript library is set to 'jQuery'.
//We need to include remoteNonStopPageScroll.js file provided by the plugin for this tag to work.
<g:javascript plugin="remote-pagination" library="remoteNonStopPageScroll"/>
<util:remoteNonStopPageScroll action='filter' total="${total}" update="listTemplateDivId" /> <util:remoteNonStopPageScroll action='filter' controller="book" total="${total}" update="listTemplateDivId" heightOffset="10" loadingHtml="loadingGifDivId" />

Description

Attributes update, action and total are required. This tag should reside in a template for example "_listTemplate.gsp", which loops through the records to be displayed iteratively.

Attributes

Events

Version History

Roadmap

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