PDA

View Full Version : CRUD never does Update action



richchri
11 Nov 2010, 11:43 AM
I'm trying to do CRUD using an EditableGrid using a data.store with an HttpProxy and writer. I haver autoSave: true and while it seems the 'Create' action works just fine whenever I update a cell in the grid instead of doing an 'Update' action it still does a 'Create'.


var userStore= new Ext.data.Store({
...
proxy: new Ext.data.HttpProxy({
method: 'POST',
api: {
read: 'getUser',
update: 'editUser',
destroy: 'delUser',
create: 'newUser',
}
}),
...
writer: new Ext.data.JsonWriter({
encode: true,
listful: true,
writeAllFields: true,
}),
autoSave: true
});

Ext.data.DataProxy.addListener('beforewrite', function(proxy, action, rs, params) {
App.setAlert(App.STATUS_NOTICE, "beforewrite: " + action + '->' + rs + '<-' + params);
});
then in the form i have the following:



onUpdate: function(btn, ev) {
console.log('onUpdate');
if (this.record == null) {
return;
}
if (!this.getForm().isValid()) {
App.setAlert(false, "Form is invalid.");
return false;
}
this.getForm().updateRecord(this.record);
},
So it seems the updateRecord is creating a 'Create' action instead of an 'Update' action. Note, that I am not defining 'updateRecord' anywhere.

Is there something glaringly wrong I'm doing I'm not seeing.

thanks.