PDA

View Full Version : DataStore changed in ExtJS3?



jasonhsu
5 May 2009, 4:27 AM
I usually define a store like this:


var store= new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(),
reader: new Ext.data.XmlReader({record: 'incidence',id:'@id'}, [
{name: 'name',mapping:'@name'},
{name: 'version',mapping:'@version'},
{name: 'amount',mapping:'@amount'},
{name: 'description',mapping:'@description'},
{name: 'analysis',mapping:'@analysis'}
]),
reloads:function(data){
this.proxy.data=data;
this.reload();
}
});

and refresh the data inside like this:

store.reloads(myData);

in which myData is data wrapped in a xml document. And it works well with ExtJS2.x, why it won't work with ExtJS 3.0 RC1.1 and give me a "Object Error" instead. Any help will be highly appreciated!!!

Condor
5 May 2009, 4:41 AM
Ext 3.0 RC1.1 has a bug in MemoryProxy (see here (http://extjs.com/forum/showthread.php?t=67076)).

jasonhsu
5 May 2009, 9:48 PM
Thanks Condor. :)

Can anyone give an idea about how I can rewrite the above code to make it work with ExtJS3.
:-?

Condor
5 May 2009, 11:42 PM
Include this override after ext-all.js:

Ext.override(Ext.data.MemoryProxy, {
doRequest : function(action, rs, params, reader, callback, scope, arg) {
params = params || {};
var result;
try {
result = reader.readRecords(this.data);
}catch(e){
this.fireEvent("loadexception", this, arg, null, e);
callback.call(scope, null, arg, false);
return;
}
callback.call(scope, result, arg, true);
}
});

jasonhsu
25 May 2009, 10:42 PM
When I use loadData(data) instead of load(data), the data can be refreshed. But loadData() method seems don't work with Grid's paging toolbar.

When I use loadData() method to refresh the data in a Store, how to make it work with the Grid's paging toolbar which shares the same store with the grid.