I created an override on Ext.data.Model to add an additional method that can be used to update the data of an existing record (model instance).
Ext.define('Ext.overrides.data.Model', { override: 'Ext.data.Model', reloadData: function(cb) { var me = this; var id = me.getId(); Ext.ModelManager.getModel(me.modelName).load(id, { callback: function(record, operation, success) { if (!success) { Ext.Error.raise('Problem reloading data from server in record'); } if (!record) { Ext.Error.raise('No record from server to reload data from'); }
Here is how you can use it. This is actually quite simple:
myRecord.reloadData(function(record, operation, success) {
Inside, it uses the load method for the linked model to create a new record. This new record is based on the same identifier as the original record on which the reloadData method was called. In the callback, the data of the new record is applied to the data of the original record. There were no events that you probably need.
This is Ext 4.2.1. There are probably a dozen scenarios that this solution breaks, but we can always clarify if we can.
Update. This solution basically implements the same as the @Drasill application. Well, well ... This test has been tested.
Christiaan westerbeek
source share