PDA

View Full Version : [FIXED]Models and Stores



sg707
16 Feb 2011, 1:30 PM
When I run below code I get

me.getProxy() is undefined



Ext.regModel('User', {
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}],
proxy: {
type: 'rest',
url: 'ajaxresponse.jsp',
reader: {
type: 'json',
root: 'users'
}
}

});

var test = new Ext.data.Store({
id: 'dataStore',
model: 'User'
});

var User = Ext.ModelMgr.getModel('User');

var ed = new User({
name : 'Ed Spencer',
age : 25
});


ed.save({
success: function(ed) {
console.log("Saved Ed! His ID is "+ ed.getId());
}
});

iesdeveloper
16 Feb 2011, 3:04 PM
sg707,

Intuitively your way should work, but I think we're actually meant to do it this way, according to docs I read:

var ed = Ext.ModelMgr.create({name : 'Ed Spencer', age : 25}, 'User');

icflorescu
17 Feb 2011, 11:17 AM
Looks like it's related to this (http://www.sencha.com/forum/showthread.php?124170-Model.save-also-fails...). I bumped into it too and I think it might be a temporary issue in the preview...

evant
17 Feb 2011, 6:38 PM
Looks like a bug. The line should read:



Ext.data.Model.override({
getProxy: function(){
return this.self.proxy;
}
});

Greendrake
20 Feb 2011, 2:42 AM
Just have come across this bug too. The solution works, but the question is: how come this bug exists? Of course I don't suppose that you guys did not test model saving and wrote the docs on it only :), but this is really weird.

evant
20 Feb 2011, 3:50 AM
There's a few things we need to clean up related to the new class system and how it works with the data model.