Groovy 分页问题
我有一个用 groovy 编写的应用程序,并且在结果集的分页方面遇到问题。
我有一个名为 ReportingController 的控制器。该控制器有两个方法称为 listdoiTln 和 listdoiEv。两种方法很相似,最后都必须呈现报告列表。两者的最后一行如下:
params.max = Math.min(params.max ? params.max.toInteger() : 15, 100)
render (view: 'list', model:[reportingInstanceList: reportingInstanceList, reportingInstanceTotal: i])
列表视图按预期呈现。在 list.gsp 文件的页脚处,我有:
<div class="paginateButtons">
<g:paginate controller="reporting" total="${reportingInstanceTotal}" max="25"/></div>
</div>
list 正在工作,分页按钮在那里,但它始终显示整个集合。请注意,我没有名为 listdoiTln.gsp 或 listdoiEv.gsp 的文件。我将 list.gsp 与不同的数据模型一起使用。
我肯定做错了什么。
有什么提示吗?
提前致谢。
路易斯
I have an application written in groovy and I am having problems with the pagination of a resulting set.
I have a Controller called ReportingController. This controller has two methods called
listdoiTln and listdoiEv. Both methods are similar and at the end both have to render a list of reports. The last lines of both are as follows:
params.max = Math.min(params.max ? params.max.toInteger() : 15, 100)
render (view: 'list', model:[reportingInstanceList: reportingInstanceList, reportingInstanceTotal: i])
The list view is rendered as expected. At the footer of the list.gsp file I have:
<div class="paginateButtons">
<g:paginate controller="reporting" total="${reportingInstanceTotal}" max="25"/></div>
</div>
The list is working, the buttons for the pagination are there but it is always displayed the whole collection. Notice that I do not have files callled listdoiTln.gsp or listdoiEv.gsp. I am using list.gsp with different data models.
Surely I am doing something wrong.
Any hint?
Thanks in advance.
Luis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也曾为此困扰过很长一段时间。试试这个:
评估控制器中的 param.offset:
params.offset = params?.offset?.toInteger() ?: 0
在模型中包含参数:
渲染(视图:'列表',
模型:[reportingInstanceList:reportingInstanceList,
报告实例总计:我,
参数:参数])
检查
reportingInstanceTotal
的值是否是您期望的值。这让我绊倒了一段时间。如果它仍然不起作用,请告诉我,或者尝试查看由
grailsgenerate-all
命令生成的 list.gsp 页面之一及其关联的控制器。分页按钮非常酷,但文档很少,而且设置它们的时间比我预期的要长。
I had trouble with this, too, for quite a while. Try this:
Evaluate param.offset in the controller:
params.offset = params?.offset?.toInteger() ?: 0
Include the params in the model:
render (view: 'list',
model:[reportingInstanceList: reportingInstanceList,
reportingInstanceTotal: i,
params: params])
Check whether the value of
reportingInstanceTotal
is the value that you expect. That tripped me up for a while.If it still doesn't work, let me know, or try looking at one of the list.gsp pages and its associated controller that are generated by the
grails generate-all
command.The paginate buttons are quite cool, but there is little documentation and it takes longer than I expected to set them up.