I want to add some pagination stuff to my grails app. I have the list action and in it I did this:
if(!params.max){
params.max = 3
}
def query = Profile.where {
userType == "F"
}
def freelancers = query.list(sort:"firstName", max:params.max)
if(freelancers) {
def freelancersCount = query.count()
return[freelancer:freelancers, fCount:freelancersCount]
} else {
response.sendError(404)
}
in gsp I wrote this:
<div id="paginate">
<g:paginate controller="freelancers" action="list" total="${fCount}"/>
</div>
everything is ok, a have a 5 objects in my db and i can see only 3 when open a gsp page in browser, but when I click on the Next to open other 2 object, I see the same 3 ones. what is wrong and what I must to do?
You need to pass the offset into your call to list:
def freelancers = query.list(sort:"firstName", offset:params.offset,
max:params.max)
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