0
votes

What is wrong with this code, because im getting all the results returning to the view, which takes me too much to load. I want it to return only 5 per page.

Controller:

{

    def channel2 = Channel2.list(params)
    //def prog = Programmation.list()
    def prog
    def progs = [:]
    def temp

    channel2.each{
       Programmation p = Programmation.withCriteria {
          eq('prog_channel', it)
          'between'('prog_start', new Date(), new Date() +1)    
        }
        progs.put(it.id, p)
    }

    [channel: channel2, program: progs]

}

GSP

<g:render id="" template="/layouts/canais"/>

<g:paginate next="Forward" prev="Back"
        maxsteps="0" max="3" controller="teste"
        action="myProgramms_canais"  
        total="${tv_megazineplus.Channel2.count()}" />

I cann't figure it out. I followed Grails helpPage, it should be working.

1
any help on this? still not workikng - recoInrelax

1 Answers

0
votes

Solution: The first time the that action is called, it loads all channels because the params.max is set to null. To fix that, just use:

def offset

        if(!params.offset){
            offset = 0
        }

        def channel2 = Channel2.list(max:5, offset: offset)