So here is one method I've come up with, but it seems terribly convoluted, so I'm wondering if I'm just doing it wrong.
Code:
Ext.define('Trigger', {
extend: 'Ext.data.Store'
, model: 'TriggerModel'
, storeId: 'triggerStore'
, autoLoad: false
, onRecordsSaved: function(operation) {
if(operation.wasSuccessful()) {
var records = operation.resultSet.records;
for(var i=0; i < records.length; ++i) {
if(records[i].getId()) {
this.add(records[i]);
}
}
}
}
, addAfterSave: function(record) {
var operation = Ext.create("Ext.data.Operation", {
action: "create"
, records: [record]});
this.getProxy().doRequest(operation, this.onRecordsSaved, this);
}
});
and then I just call it with:
Code:
store.addAfterSave(store.createModel({name:alertName, active:true}));
And all the magic just happens. One thing that makes me think something is wrong here is the call to proxy.commitRecords which basically ends up doing nothing.
I still end up using the exception on the proxy object to display the error messages, but at least now I don't have orphans in the grid after a failure to save.