grails paginate不起作用 [英] grails paginate doesn't work

查看:106
本文介绍了grails paginate不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在控制器中:

  def show(Integer max){
params.max = Math.min(max?:10,100)
def etpse
def (params.data =='all'){

etpse = Enterprise.findAll()
total = Enterprise.count()$ b $总共

b}

else {
def paramsLike =%+ params.data +%
etpse = Enterprise.findAllByKeywordLike(paramsLike)
total = Enterprise。 countByKeywordLike(paramsLike)
}

[etpseList:etpse,instanceTotal:total]
}

gsp:

 < div id ='pagination'> 
< / div>


解决方案

b

  def show(Integer max){

整数偏移量= params.int(偏移量)
整数最大值= Math.min(params.int(max)?:10,100)

if(params.data =='all'){
params.data ='%';


def c = Enterprise.createCriteria()
def results = c.list(max:max,offset:offset){
ilike('keyword' ,%+ params.data +%)
}


[etpseList:results,instanceTotal:results.totalCount]
}


I'm trying to use the paginate tag in grails but it isn't working.

in controller:

def show(Integer max) {
    params.max = Math.min(max ?: 10, 100)
    def etpse
    def total

    if (params.data == 'all') {

        etpse = Enterprise.findAll()
        total = Enterprise.count()
    }

    else {
        def paramsLike = "%" + params.data + "%"
        etpse = Enterprise.findAllByKeywordLike(paramsLike)
        total = Enterprise.countByKeywordLike(paramsLike)
    }

    [etpseList: etpse, instanceTotal: total]
}

in gsp:

<div id='pagination'>
    <g:paginate total="${instanceTotal}" />
</div>

解决方案

Here you go.

def show(Integer max) {

    Integer offset = params.int("offset")
    Integer max = Math.min(params.int("max") ?: 10, 100)

    if (params.data == 'all') {
        params.data = '%';
    }

    def c = Enterprise.createCriteria()
    def results = c.list(max: max, offset: offset) {
      ilike('keyword', "%" + params.data + "%")
    }


    [etpseList: results, instanceTotal: results.totalCount]
}

这篇关于grails paginate不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆