【发布时间】:2012-03-24 07:35:35
【问题描述】:
我正在使用 ExtJS 3.3.1 和 Grails 2.0 在屏幕上进行分页,但它并没有像我预期的那样工作。
我按照此处发布的提示进行操作:Grails extJS grid paging
JS页面
paramNames: {start:'offset',limit:'max',sort:'sort',dir:'order'},
baseParams: {offset:0,max:10},
分页工具栏:
this.gridBBar = new Ext.PagingToolbar({
pageSize : 10,
store : this.gridStore,
displayInfo : true,
displayMsg : 'Hiển thị {0} - {1} mục tìm được của {2} kết quả',
emptyMsg : 'Không tìm thấy dữ liệu',
});
控制器:
def result = Floor.createCriteria().list(
max:params.int('max')?:100,
offset:params.int('offset')?:0
)
render ([count:result.totalCount,data:result] as JSON)
但分页按钮(下一步)被禁用,因为商店只包含 10 件商品,没有更多可检索的商品。
当我将偏移量更改为 10 时:
paramNames: {start:'offset',limit:'max',sort:'sort',dir:'order'},
baseParams: {offset:10,max:10},
分页效果很好,除了一件奇怪的事情:网格总是显示接下来的 10 个结果(第一次点击的第 10-20 条记录,第 2 次点击的第 20-30 条记录),而不是当前的前 10 个结果。我不知道 ExtJs 和 Grails 结合的分页的正确用法是什么。如果您有此问题的经验,能否请您分享一些信息?
非常感谢。
【问题讨论】:
-
你的 json 是什么样的?你可能想看看这个:shitmores.blogspot.com/2007/04/…
-
返回的 JSON 为 {"count":10, "items":[{"id":1, "name" : "AA"}, {"id":2, "name" :“B”}]}。我看到语句 render ([count:result.totalCount,data:result] as JSON) 不正确,因为返回列表没有 getTotalCount() 方法或 totalCount 属性
标签: grails extjs pagination