2011-12-13 2 views
0

이 코드의 잘못된 점은 모든 결과가 뷰로 돌아 오기 때문에로드가 너무 많이 걸리기 때문입니다. 페이지 당 5 개만 반환하고 싶습니다.Grails 페이지 매김 사용

컨트롤러 :

{ 

    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()}" /> 

나는 그것을 알아 두지. 나는 Grails helpPage를 따라 갔다.

+0

어떤 도움이 필요합니까? 여전히 작동하지 않는다. – recoInrelax

답변

0

해결 방법 : 해당 동작이 처음 호출 될 때 params.max가 null로 설정되어 있기 때문에 모든 채널을로드합니다. 이를 수정하려면 다음을 사용하십시오.

def offset 

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

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