【问题标题】:Make grails pagination使 grails 分页
【发布时间】:2013-07-01 11:18:00
【问题描述】:

我的控制器以这样的数组返回结果:

 render (template: 'show' , model: [changes: changes])

显示是默认操作,更改是使用查询创建的数组 (createCriteria)。 如何在我的index.gsp 页面中进行分页,该页面在 HTMl div 中显示结果?

我的问题:

控制器:

def list() {
        [terminHistorie: changes, terminHistorieCount: changes.size()]
    }

gsp:

<g:paginate controller="terminHistorie" action="list" total="${terminHistorieCount}"/>

错误:标签 [paginate] 在 C:/Users/matejb/Documents/NetBeansProjects/gutmann/grails-app/views/terminHistory/index.gsp:309 处缺少必需的属性 [total]

【问题讨论】:

    标签: html grails pagination


    【解决方案1】:

    分页的工作方式是您首先需要使用分页标签创建一个视图,然后在您的显示操作中您需要对更改进行切片。这意味着视图将发送 offset 和 max 参数,而您的 createCriteria 将仅查询数据库中的这些数据。看看这个page,然后看看here,看看如何将 max 和 offset 传递到 createCriteria 方法中。

    要查看示例,请参阅此page 或创建具有一个简单域的新应用程序并为其生成脚手架。 Grails 将为您生成分页结果。

    顺便说一句,如果您使用 ajax,您可能需要使用 remote paginate 插件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-26
      • 1970-01-01
      • 1970-01-01
      • 2012-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多