Sencha中List插件plugin(ListPaging)上拉翻页提示文字始终是“更多...”
情景描述:使用List组件中分页的插件plugins时,当通过下拉翻至最后一页时,提示文字并为由“更多....”变为“没有更多条记录了”,而且下拉事件也未禁用掉。
完整代码如下:
plugins: [ { xclass: 'Ext.plugin.PullRefresh', pullRefreshText: '下拉可以更新', releaseRefreshText: '松开开始更新', loading: '正在刷新……', refreshFn: function (loaded, arguments) { loaded.getList().getStore().loadPage(1, { callback: function (record, operation, success) { Ext.Viewport.unmask(); }, scope: this }); } }, { xclass: 'Ext.plugin.ListPaging', loadMoreText: '更多……', noMoreRecordsText: '没有更多条记录了', autoPaging: true //设置为TRUE将自动触发 } ]
解决方法:查看sencha-touch API文档ListPagin的源码可知:
message = this.storeFullyLoaded() ? this.getNoMoreRecordsText() : this.getLoadMoreText(); storeFullyLoaded: function() { var store = this.getList().getStore(), total = store.getTotalCount(); return total !== null ? store.getTotalCount() <= (store.currentPage * store.getPageSize()) : false; }
当storeFullyLoaded()函数返回true时,应该显示noMoreRecordsText值,因此可以想到是后台没有将TotalCount值返回到客户端。
如果客户端store中没有设置【totalProperty:string】属性时,sencha默认用【total】属性装载TotalCount值,所以开发后台逻辑时,请将查询记录总数以{total:25}形式返回到客户端即可!
注:当有多个返回节点时,记得是放在根节点下!!