martinrame
11 Feb 2012, 1:51 PM
In a controller I have an event handler for a form's button. Also I have a model instance called "customer" with an ajax json proxy with "Create/Update/Insert/Delete" urls configured, and it works ok.
I use this form to edit a record (model) part of a store. When I do an Update operation, the grid that shows the store is updated automatically, but on Inserts, I'm forced to do "this.getMyJsonStoreStore().load()" on the "success" event.
Is there an transparent way to notify the store about the new record?. If not, how can I determine if the model was Updated/Deleted or Created (I only need to load the store after Insert or Delete, not for Updates).
This is my code so far:
onSubmit: function(button) { var win = button.up('frmCustomer');
frm = win.getForm();
customer = frm.getRecord();
frm.updateRecord(customer);
customer.save({
success: function(customer){
this.getMyJsonStoreStore().load();
win.destroy();
},
failure: function(customer){
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
},
scope: this
});
},
I use this form to edit a record (model) part of a store. When I do an Update operation, the grid that shows the store is updated automatically, but on Inserts, I'm forced to do "this.getMyJsonStoreStore().load()" on the "success" event.
Is there an transparent way to notify the store about the new record?. If not, how can I determine if the model was Updated/Deleted or Created (I only need to load the store after Insert or Delete, not for Updates).
This is my code so far:
onSubmit: function(button) { var win = button.up('frmCustomer');
frm = win.getForm();
customer = frm.getRecord();
frm.updateRecord(customer);
customer.save({
success: function(customer){
this.getMyJsonStoreStore().load();
win.destroy();
},
failure: function(customer){
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
},
scope: this
});
},