Great thread and great tips. I think a lot of us needed this. Regarding Animal's buffered rendering suggestions, I am getting an incorrect behaviour, on both 4.0.7 and 4.1-pr1. I do not know if I am doing something wrong or if it is a bug. If someone has a clue either way, please let me know
I am loading a buffered store in FF 7.0.1 and monitoring the XHR calls through firebug. The buffer is correctly loaded through the proxy. But when I use myStore.load(0, 49) the whole store is loaded again via the proxy and the full table is rendered, which kind of defeats the purpose.
my test setup (I simplified it as much as I could think of)
Code:
Ext.define('edm.model.Doc', { extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'}
],
proxy: {
type: 'rest',
url: '/docs',
reader: {
type: 'json',
root: "data",
defaultRootId: 'root'
}
},
constructor: function() {
this.callParent(arguments);
},
});
Ext.define('edm.store.Docs', {
extend: 'Ext.data.Store',
model: 'edm.model.Doc',
buffered: true,
purgePageCount: 0,
clearOnPageLoad: false
});
myStore = Ext.create('edm.store.Docs');
myStore.prefetch({
start: 0,
limit: 999999,
callback: function() {
console.log('prefetched')
myStore.load(0, 49);
console.log('loaded')
}
});
the firebug output:
Code:
GET http:/127.0.0.1/docs?_dc=1321107103812&start=0&limit=999999
prefetched
GET http:/127.0.0.1/docs?_dc=1321107104216&page=1&start=0&limit=25
loaded
I later use the console to check the store is correctly loaded:
Code:
>>console.log(myStore.first().get('id'))
1
Update: I also tried to use myStore.load({start:0, limit: 50}); but the proxy is still accessed instead of the buffer.
Update: I got it to work by replacing store.load by store.guaranteeRange and adding a pageSize parameter to the store:
Code:
Ext.define('edm.model.Doc', { extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'}
],
proxy: {
type: 'rest',
url: '/docs',
reader: {
type: 'json',
root: "data",
defaultRootId: 'root'
}
},
constructor: function() {
this.callParent(arguments);
},
});
Ext.define('edm.store.Docs', {
extend: 'Ext.data.Store',
model: 'edm.model.Doc',
pageSize: 50,
buffered: true,
purgePageCount: 0,
clearOnPageLoad: false
});
myStore = Ext.create('edm.store.Docs');
myStore.prefetch({
start: 0,
limit: 999999,
callback: function() {
console.log('prefetched')
myStore.guaranteeRange(0, 49);
console.log('loaded')
}
});
the firebug output is now:
Code:
GET http:/127.0.0.1/docs?_dc=1321107103812&start=0&limit=999999
prefetched
loaded