Perform Pagination Manually on List in Grails

Posted By : Varun Sharma | 23-Apr-2014

We have Remote Pagination Plugin in Grails to carryout pagination operations but that is little bit complex to operate with. Also Remote Pagination mostly used in views to paginate through list.

But, what if we need pagination on a list manually like rewuest from mobile app etc. I went through this problem & solved by using the below piece of code.

 

def getPaginatedList(list, max, offset) {
		max = Math.min(max ?: 10, 100)
		offset = offset?:0
                int total = list.size()
		int upperLimit = (offset+max (greterThanEqualto) total?total:offset+max)-1
		return offset (lessThan) total ? list.getAt(offset..upperLimit) : []	
}	

 

Just pass your list, give max count along with offset i.e; from where you want list to begin and this will return you list that is desired.


>Hope it helps !

Varun Sharma [email protected]

http://oodlestechnologies.com/

About Author

Author Image
Varun Sharma

Varun is an experienced Groovy and Grails developer and has worked extensively on designing and developing applications with FaceBook , Linkedin and Twitter integrations using Grails technologies. Varun loves painting and photography.

Request for Proposal

Name is required

Comment is required

Sending message..
Yono Rummy YonoRummy Rummy Codes Rummy Promo Codes Rummy Yono App Yono Rummy APK Game Yono Rummy Yono Rummy Games sarkari naukri dunia TOTOSGP TOTO SGP TOTOSGP TOTO SGP TOTOSGP TOTOSGP India Games Online Platform Popular Games in India India Gaming Experience Online Games India Best Rummy Games in India India Games Collection Teen Patti Games India Rummy Games Online India India Rummy Gaming Platform Popular Rummy Platform India Online Rummy Games India India Mobile Gaming India Gaming Platform Indian Online Games India Games and Entertainment India Gaming Community India Online Gaming Platform Teen Patti Online Games India Rummy and Teen Patti Games