May 12, 2014, 8:35 PM
[CLOSED] Implementing paging in custom store proxy
Last week you've helped me to implement a custom proxy, to use DirectMethod to search for combobox registers.
It is working fine, but since there are tables with too many records, i need to implement some kind of paging.
I've noticed that, the received parameter "params" in the method doRequest, i can know in which page i'm in, because it provides me the "start" and the "limit" properties, the "limit" being the page size i configured in the combobox.
I just need to know how to inform the store how many registers are there in total, so that it knows how many pages it must have. Since i'll return in the DirectMethod only as many records as configured in the PageSize, somewhere i need to make a "SELECT COUNT" in the server and inform the combobox / store hor many registers are there, so it knows how many pages. How to?
It is working fine, but since there are tables with too many records, i need to implement some kind of paging.
I've noticed that, the received parameter "params" in the method doRequest, i can know in which page i'm in, because it provides me the "start" and the "limit" properties, the "limit" being the page size i configured in the combobox.
I just need to know how to inform the store how many registers are there in total, so that it knows how many pages it must have. Since i'll return in the DirectMethod only as many records as configured in the PageSize, somewhere i need to make a "SELECT COUNT" in the server and inform the combobox / store hor many registers are there, so it knows how many pages. How to?
Ext.net.DirectMethodProxy = function () {
var api = {};
api[Ext.data.Api.actions.read] = true;
Ext.net.DirectMethodProxy.superclass.constructor.call(this, {
api: api
});
};
Ext.extend(Ext.net.DirectMethodProxy, Ext.data.DataProxy, {
ro: {},
isDataProxy: true,
doRequest: function (action, rs, params, reader, callback, scope, arg) {
if (this.fireEvent("beforeload", this, params) !== false) {
this.ro = {
params: params || {},
request: {
callback: callback,
scope: scope,
arg: arg
},
reader: reader,
callback: this.loadResponse,
scope: this
};
var config = {
proxy: this,
success: this.successHandler
};
var helpfield = Ext.getCmp(scope.comboId);
Ext.net.DirectMethods.LoadHelpFieldComboboxData(helpfield.getHelpClass(), helpfield.getHelpIndex(), helpfield.getParamValues(), params.query, config);
} else {
callback.call(scope || this, null, arg, false);
}
},
successHandler: function (result, response, extraParams, o) {
var p = o.proxy;
result = p.ro.reader.readRecords(JSON.parse(result));
p.fireEvent("load", p, p.ro, p.ro.request.arg);
p.ro.request.callback.call(p.ro.request.scope, result, p.ro.request.arg, true);
}
});
Last edited by Daniil; May 20, 2014 at 7:53 AM.
Reason: [CLOSED]