0
votes

Today when i customize list method of my controller,facing issue in list.gsp page.My problem is that all records are displayed on a single page. for ex. Suppose i have 15 records then all 15 will show on first page and also there in next link at footer.when clicks on it all pages show same 15 records.

I was customize code because i need to run query and basis of result of query show records on list page.

def query = "from Book where isAvailable = 'true'"
        def bookInstanceList = Book.findAll(query)
        [bookInstanceList: bookInstanceList , bookInstanceTotal: bookInstanceList.size()]

it shows all records on a single page and records are not paginate on different page. i want to show maximum 10 records on each page.

please reply me where i am missing.

Thanks in advance

1

1 Answers

2
votes

So pagination will not work that way. You are getting your total of the resulting number of rows that were returned, not what would have been returned without pagination.

def bookQuery = Book.where{ isAvailable == 'true' }
[bookInstanceList: bookQuery.list(params), bookInstanceTotal: bookQuery.count()]

params should contain max and offset to implement pagination.