PDA

View Full Version : MemoryProxy error on model.save()



Support@regware.be
25 Jan 2013, 7:21 AM
When using a Store with a MemoryProxy and JsonReader, if you try to save an updated model of that store, you get an error

ex:
SalesStore config

Ext.define('MyApp.store.SalesStore', {
extend: 'Ext.data.Store',


requires: [
'MyApp.model.SalesItem'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
storeId: 'SalesStore',
model: 'MyApp.model.SalesItem',
proxy: {
type: 'memory',
reader: {
type: 'json'
}
}
}, cfg)]);
}


});

var salesRec = this.getSalesStoreStore().findRecord('userkey', button.userKey);
if (salesRec) {


salesRec.data.qty += 1;
salesRec.save();
}

this gave an error : TypeError: url is undefined




chrome://firebug/content/blank.gif

return url + (url.indexOf('?') === -1 ? '?' : '&') + string;




Of course with a memory proxy, there is no url....
is it a bug ? or a mis usage ?

mitchellsimoens
25 Jan 2013, 10:32 AM
If you are using a memory proxy, why do you need to save the model? When you set the data to the model, it's technically already saved for a memory proxy.

Support@regware.be
25 Jan 2013, 1:55 PM
I would like to have the store datachanged event to be raised.
It is not raised in the case of using set.
My point of view is that the store should work the same independently of the proxy used; if you use a Memory proxy or a json proxy your code implementation should not be change....
Correct ?