Hi, not sure exactly what you are trying to do, but I created an example that might help...
You pass a function to the FunctionProxy constructor. The function will get called with the arguments provided to the store.load function. The provided function must return a valid JSON object for the reader.
Code:
FunctionProxy = Ext.extend(Ext.data.DataProxy, {
constructor: function(fn) {
var api = {};
api[Ext.data.Api.actions.read] = true;
FunctionProxy.superclass.constructor.call(this, {
api: api
});
this.fn = fn;
},
doRequest : function(action, rs, params, reader, callback, scope, arg) {
params = params || {};
var result;
try {
result = reader.readRecords(this.fn(params));
} catch(e) {
// @deprecated loadexception
this.fireEvent("loadexception", this, null, arg, e);
this.fireEvent('exception', this, 'response', action, arg, null, e);
callback.call(scope, null, arg, false);
return;
}
callback.call(scope, result, arg, true);
}
});
var store = new Ext.data.JsonStore({
root: 'data',
idProperty: 'id',
totalProperty: 'count',
fields: ['id', 'text'],
proxy: new FunctionProxy(function() {
return {
data: [
{ id: 1, text: 'Test' },
{ id: 2, text: 'Test 2' }
],
count: 2,
success: true,
message: ''
};
}),
listeners: {
'load': function() {
console.log(this.getCount());
}
}
});
store.load();