I was trying to pass params to my directFn function in Ext.data.DataStores but none of the way is working. By looking at source i found API Docs and source does not match. Can some one help me out.
My Source
Code:
new Ext.data.DirectStore({
storeId:'plugin-man',
paramsAsHash:false,
autoLoad:true,
directFn:Ext.ss.forge_configManager.read_details,
paramOrder:'interfaceMan_pluginDetails',
fields:['pluginName','pluginDescription','pluginPid','pluginModule','startup','startTime','stopTime','status']
})
ext-all-debug.js
Code:
Ext.data.DirectProxy = function(config){
if(typeof this.paramOrder == 'string'){
this.paramOrder = this.paramOrder.split(/[\s,|]/);
}
Ext.data.DirectProxy.superclass.constructor.call(this, config);
};
Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
paramOrder: undefined,
paramsAsHash: true,
directFn : undefined,
// protected
doRequest : function(action, rs, params, reader, callback, scope, options) {
var args = [];
var directFn = this.api[action] || this.directFn;
switch (action) {
case Ext.data.Api.CREATE:
args.push(params[reader.meta.root]); // <-- create(Hash)
break;
case Ext.data.Api.READ:
if(this.paramOrder){
for(var i = 0, len = this.paramOrder.length; i < len; i++){
args.push(params[this.paramOrder[i]]);
}
}else if(this.paramsAsHash){
args.push(params);
}
break;
case Ext.data.Api.UPDATE:
args.push(params[reader.meta.idProperty]); // <-- save(Integer/Integer[], Hash/Hash[])
args.push(params[reader.meta.root]);
break;
case Ext.data.Api.DESTROY:
args.push(params[reader.meta.root]); // <-- destroy(Int/Int[])
break;
}
args.push(this.createCallback(action, reader, callback, scope, options));
directFn.apply(window, args);
},
// private
createCallback : function(action, reader, callback, scope, arg) {
return {
callback: (action == Ext.data.Api.READ) ? function(result, e){
if (!e.status) {
this.fireEvent(action+"exception", this, e, result);
callback.call(scope, null, arg, false);
return;
}
var records;
try {
records = reader.readRecords(result);
}
catch (ex) {
this.fireEvent("writeexception", this, action, e, result, ex);
callback.call(scope, null, arg, false);
return;
}
this.fireEvent("write", this, action, e, arg);
callback.call(scope, records, arg, true);
} : function(result, e){
if(!e.status){
this.fireEvent("writeexception", this, action, e);
callback.call(scope, null, e, false);
return;
}
this.fireEvent("write", this, action, result, e, arg);
callback.call(scope, result, e, true);
},
scope: this
}
}
});
Docs Source
Code:
/**
* @class Ext.data.DirectProxy
* @extends Ext.data.DataProxy
*/
Ext.data.DirectProxy = function(config){
Ext.apply(this, config);
if(typeof this.paramOrder == 'string'){
this.paramOrder = this.paramOrder.split(/[\s,|]/);
}
Ext.data.DirectProxy.superclass.constructor.call(this);
};
Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
/**
* @cfg {Array/String} paramOrder Defaults to undefined. A list of params to be executed
* server side. Specify the params in the order in which they must be executed on the server-side
* as either (1) an Array of String values, or (2) a String of params delimited by either whitespace,
* comma, or pipe. For example,
* any of the following would be acceptable:
paramOrder: ['param1','param2','param3']
paramOrder: 'param1 param2 param3'
paramOrder: 'param1,param2,param3'
paramOrder: 'param1|param2|param'
*/
paramOrder: undefined,
/**
* @cfg {Boolean} paramsAsHash
* Send parameters as a collection of named arguments (defaults to true). Providing a
* {@link #paramOrder} nullifies this configuration.
*/
paramsAsHash: true,
// protected
doRequest : function(action, rs, params, reader, writer, cb, scope, options) {
var args = [];
var directFn = this.api[action];
switch (action) {
case 'save':
args.push(params[reader.meta.idProperty]); // <-- save(Integer/Integer[], Hash/Hash[])
args.push(params[writer.dataProperty]);
break;
case 'destroy':
args.push(params[writer.dataProperty]); // <-- destroy(Int/Int[])
break;
case 'create':
args.push(params[writer.dataProperty]); // <-- create(Hash)
break;
case 'load':
args.push(params); // <-- load(Hash)
break;
}
args.push(this.createCallback(action, reader, cb, scope, options));
directFn.apply(window, args);
},
// private
createCallback : function(action, reader, cb, scope, arg) {
return {
callback: (action == 'load') ? function(result, e){
if (!e.status) {
this.fireEvent(action+"exception", this, e, result);
cb.call(scope, null, arg, false);
return;
}
var records;
try {
records = reader.readRecords(result);
}
catch (ex) {
this.fireEvent(action+"exception", this, e, result, ex);
cb.call(scope, null, arg, false);
return;
}
this.fireEvent(action, this, e, arg);
cb.call(scope, records, arg, true);
} : function(result, e){
if(!e.status){
this.fireEvent(action+"exception", this, e);
cb.call(scope, null, e, false);
return;
}
this.fireEvent(action, this, result, e, arg);
cb.call(scope, result, e, true);
},
scope: this
}
}
});