I have some list data and I want to do pagination. But I don't understand how to use 'max'. Here is my simple query code,
def users = User.where{
roles {
id in roles.id
}
}.list(max: 1)
println users
And I didn't understand what is offset. If I want show 5 data per page, What is my offset should be ?
Write like this one, I took it from official docs:
def users = User.createCriteria().list (max: 10, offset: 10) {
roles {
'in'('id', roles*.id)
}
}
link to createCriteria docs You can take on controller params.offset and params.max and use it in those criteria. For example:
def users = User.createCriteria().list (max: params.max, offset: param.offset) {...}
I think you can add some links under list of elements with offset what you want. Good luck :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With