PDA

View Full Version : Record not updated after save in ExtJs 4.1.3



samks
10 Dec 2012, 3:01 PM
Looking at ExtJs source code 4.1.3, I find that model.save() is now missing the following code from ExtJs 4.0.7:




//we need to make sure we've set the updated data here. Ideally this will be redundant once the
//ModelCache is in place
me.set(record.data);

The missing code results in the frontend not updating the record. I'm not sure if this is a bug. If anyone can provide an explanation or suggestion, that will be great. Currently I am just calling a similar code in my success function to make it work.

mitchellsimoens
12 Dec 2012, 8:30 AM
Working for me. This code:


Ext.define('User', {
extend : 'Ext.data.Model',

fields : [
'first',
'last'
],

proxy : {
type : 'ajax',
url : 'data/json.json',
reader : {
type : 'json',
root : 'data'
}
}
});

var user = new User({
first : 'Mitch'
});

user.save({
callback : function(rec) {
console.log(rec);
}
});

With this response:


{
"success" : true,
"data" : {
"first" : "Mitchell",
"last" : "Simoens"
}
}

changes the first and last field values to the response.