[CLOSED] Implementing paging in custom store proxy

  1. #1

    [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?

    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]
  2. #2
    Hi @josegarcia,

    Hmm, I am not 100% sure, but you probably just need to return a total with a server response in the same way as it is done with other type of Proxies. It should be picked up. Have you tried that?
  3. #3
    What do you mean? Return all the items? I've tried. Let's say i have 100 registers and want a page of size 10.
    If i return the 100 registers it shows the correct number of pages (like "page 1 of 10"), but won't page correctly, for every page shows the whole 100 items. Also it gets sluggish for big tables, because although it's paged all items are sent to the client.
    I'm trying to figure out how to return from the server and bind to the store only 10 records for each page, but somehow inform the store that there are 100 registers total, so it knows how to render the "page 1 of 10" stuff.
  4. #4
    I meant the total amount of records. It is required for remote paging.

    Please look at this example:
    https://examples2.ext.net/#/GridPane.../DirectMethod/

    Code behind, this line:
    return new { data, total };

Similar Threads

  1. Replies: 3
    Last Post: May 06, 2013, 11:52 AM
  2. Replies: 13
    Last Post: Sep 07, 2012, 6:23 PM
  3. [CLOSED] [Razor] Paging without Store Proxy
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 04, 2012, 2:52 AM
  4. Replies: 0
    Last Post: Jun 03, 2012, 3:46 AM
  5. Replies: 0
    Last Post: Oct 06, 2011, 1:38 PM

Posting Permissions