Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GrailsExtJS分页_Grails_Extjs_Pagination - Fatal编程技术网

GrailsExtJS分页

GrailsExtJS分页,grails,extjs,pagination,Grails,Extjs,Pagination,我正在使用带有Grails2.0的ExtJS3.3.1在屏幕上进行分页,但它并没有像我预期的那样工作。 我遵循了这里发布的提示: JS页面 paramNames: {start:'offset',limit:'max',sort:'sort',dir:'order'}, baseParams: {offset:0,max:10}, 分页工具栏: this.gridBBar = new Ext.PagingToolbar({ pageSize : 10,

我正在使用带有Grails2.0的ExtJS3.3.1在屏幕上进行分页,但它并没有像我预期的那样工作。 我遵循了这里发布的提示:
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个结果(第1次单击的是第10-20条记录,第2次单击的是第20-30条记录),而不是当前的前10个结果。我不知道ExtJs和Grails组合的分页的正确用法是什么。如果您在这个问题上有经验,可以与我分享一些信息吗?

非常感谢。

哦,我真幸运。我明白了
基于这两篇文章:
1.

2.
我已经找到了解释。因为JSON中返回的“count”属性是从result.size()获得的,所以它始终等于网格存储区PagingToolbar的pageSize,因此存储区会理解,不再有任何结果可检索,并且会禁用导航按钮。
这里的关键是返回查询的实际总结果(不附加分页约束)。与正常情况一样,createCriteria().list{}将返回ArraysList。但通过如下方式将分页参数传递给列表:(参考链接1)

Grails将隐式地以PagedResultList的形式返回结果(请参阅链接2),并向我们提供getTotalCount()。没有任何关于Grails的官方文档提到这个神奇的问题。
我的问题就解决了。

你的json是什么样子的?您可能想看看这个:返回的JSON是{“count”:10,“items”:[{“id”:1,“name”:“AA”},{“id”:2,“name”:“B”}]}。我发现语句呈现([count:result.totalCount,data:result]为JSON)不正确,因为返回列表没有getTotalCount()方法或totalCount属性
DomainClass.createCriteria().list(max : x, offset : y) { 
// not pass max : x, offset : y to here, inside the body
}