ExtJS:alterstorepagesize
假设我有一家商店:ExtJS:alterstorepagesize,extjs,pagination,store,extjs4.2,Extjs,Pagination,Store,Extjs4.2,假设我有一家商店: Ext.define('MyApp.store.MyTestStore', { extend: 'Ext.data.Store', alias: 'store.MyTestStore', requires: [ 'MyApp.model.MyTestModel' ], constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({
Ext.define('MyApp.store.MyTestStore', {
extend: 'Ext.data.Store',
alias: 'store.MyTestStore',
requires: [
'MyApp.model.MyTestModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
model: 'MyApp.model.MyTestModel',
remoteFilter: true,
remoteSort: true,
storeId: 'MyTestStore',
buffered: true,
pageSize: 100,
listeners: {
load: {
fn: me.onStoreLoad,
scope: me
},
beforeload: {
fn: me.onStoreBeforeLoad,
scope: me
}
}
}, cfg)]);
},
onStoreLoad: function(store, records, successful, eOpts) {
console.log('load', records.length);
},
onStoreBeforeLoad: function(store, operation, eOpts) {
console.log('beforeload',operation);
}
});
如您所见,最初我使用pageSize:100加载它,这非常适合我最初加载此存储时使用,但稍后我希望能够加载所有内容,也就是说,我希望能够更改pageSize。我尝试了以下方法:
Ext.getStore('MyTestStore').reload({params:{start:0, limit:50000}});
Ext.getStore('MyTestStore').reload({start:0, limit:50000, page:1, addRecords:true});
Ext.getStore('MyTestStore').reload({start:0, limit:50000, page:1, addRecords:true, callback : function(r, options, success) {
console.log(r.length,success)
}});
但两者似乎都不起作用。我想这显然是因为页面大小仍然设置为100。所以我去了,并在飞行中更新了商店:
Ext.getStore('MyTestStore').lastPageSize = 50000;
Ext.getStore('MyTestStore').pageSize = 50000;
Ext.getStore('MyTestStore').pageMap.pageSize = 50000;
现在,当我运行console.log(Ext.getStore('MyTestStore'))时,一切都正常显示,但我仍然只得到100条记录。我查看了从服务器返回的代码,并正确地获取了每条记录,但是当函数“onload”运行到记录计数以上时,记录计数保持在100。有没有办法改变它,强迫它改变自己的页面大小
编辑(其他信息):
所以另一个奇怪的部分是当我做以下事情时:
Ext.getStore('MyTestStore').reload({params:{start:0, limit:50000}});
Ext.getStore('MyTestStore').reload({start:0, limit:50000, page:1, addRecords:true});
Ext.getStore('MyTestStore').reload({start:0, limit:50000, page:1, addRecords:true, callback : function(r, options, success) {
console.log(r.length,success)
}});
我回来了:
load 100
6362 true
在我的控制台里。第一行来自“onStoreLoad”功能,第二行来自我的重新加载功能。很明显,我正在取回我的所有记录,但其中大部分记录都被阻止了。更改存储配置中的页面大小。您可以调用nextPage()进入下一页 如果要更改每页的编号记录,可以使用带有页码和选项的loadPage。看见您可以使用与示例中相同的选项 试试这个,让我知道。试试这个:
Ext.getStore('MyTestStore').reload({start:0, limit:50000});
Ext.apply(Ext.getStore('MyTestStore'), {pageSize: 50000});
“limit”和“pageSize”应保留该值