87,910
社区成员
发帖
与我相关
我的任务
分享
/**
* @private
* Fake processing function to commit the records, set the current operation
* to successful and call the callback if provided. This function is shared
* by the create, update and destroy methods to perform the bare minimum
* processing required for the proxy to register a result from the action.
*/
updateOperation: function(operation, callback, scope) {
var i = 0,
recs = operation.getRecords(),
len = recs.length;
for (i; i < len; i++) {
recs[i].commit();
}
operation.setCompleted();
operation.setSuccessful();
Ext.callback(callback, scope || this, [operation]);
},
/**
* Currently this is a hard-coded method that simply commits any records and sets the operation to successful,
* then calls the callback function, if provided. It is essentially mocking a server call in memory, but since
* there is no real back end in this case there's not much else to do. This method can be easily overridden to
* implement more complex logic if needed.
* @param {Ext.data.Operation} operation The Operation to perform
* @param {Function} callback Callback function to be called when the Operation has completed (whether
* successful or not)
* @param {Object} scope Scope to execute the callback function in
* @method
*/
create: function() {
this.updateOperation.apply(this, arguments);
},
/**
* Currently this is a hard-coded method that simply commits any records and sets the operation to successful,
* then calls the callback function, if provided. It is essentially mocking a server call in memory, but since
* there is no real back end in this case there's not much else to do. This method can be easily overridden to
* implement more complex logic if needed.
* @param {Ext.data.Operation} operation The Operation to perform
* @param {Function} callback Callback function to be called when the Operation has completed (whether
* successful or not)
* @param {Object} scope Scope to execute the callback function in
* @method
*/
update: function() {
this.updateOperation.apply(this, arguments);
},
/**
* Currently this is a hard-coded method that simply commits any records and sets the operation to successful,
* then calls the callback function, if provided. It is essentially mocking a server call in memory, but since
* there is no real back end in this case there's not much else to do. This method can be easily overridden to
* implement more complex logic if needed.
* @param {Ext.data.Operation} operation The Operation to perform
* @param {Function} callback Callback function to be called when the Operation has completed (whether
* successful or not)
* @param {Object} scope Scope to execute the callback function in
* @method
*/
destroy: function() {
this.updateOperation.apply(this, arguments);
},
/**
* Reads data from the configured {@link #data} object. Uses the Proxy's {@link #reader}, if present.
* @param {Ext.data.Operation} operation The read Operation
* @param {Function} callback The callback to call when reading has completed
* @param {Object} scope The scope to call the callback function in
*/
read: function(operation, callback, scope) {
var me = this,
reader = me.getReader(),
result = reader.read(me.data);
Ext.apply(operation, {
resultSet: result
});
operation.setCompleted();
operation.setSuccessful();
Ext.callback(callback, scope || me, [operation]);
},