I have a query which gives a result of about 100 rows. Here is the code for the controllers
def bandsOneTrack = {
def bands = Band.executeQuery("Select b from Band as b where size(b.tracks) > (select count(t.id) from Band as ba join ba.tracks as t where ba.id = b.id and t.ourContract is not null) and (select count(t.id) from Band as ba join ba.tracks as t where ba.id = b.id and t.ourContract is not null) >= 1" )
render(view: 'bands_list' , model: [ bands : bands ])
}
It gives me the result set of about 100 rows but they are appearing inside a same page.
Now I want to use pagination so that I can restrict it to only 20 rows per page.
What should I do, and also how to use pagination for this.
On your pagination tag check the total parameter. That should be the total number of records. In your case 100 so that the pagination tag can calculate the total number of pages.
Something like this here:
You might need to execute your query once to find the total number of records.