Search code examples
c#asp.net-mvc-3extjsparameterspagination

How to pass additional parameters for paging


I know paging requires start and limit parameters that is passed to the controller... but I also use couple more parameters that needs to be passed... which is 'STATE' and 'ID'... I tried baseParams, params... nothing works... this is my store

this.myStore = Ext.create('Ext.data.Store', {
        scope: this,
        storeId: 'myStore',
        fields: [
            { name: 'State', type: 'string' },
            { name: 'ID', type: 'string' }
        ],
        proxy: {
            type: 'ajax',
            scope: this,
            extraParams: { State: '', ID: '', start: 1, limit: 200 },
            url: 'myControl/getRecords',
            reader: {
                type: 'json',
                totalProperty: 'count',
                root: 'data'
            }
        },
        autoLoad: true
    });

I know I don't have to use start and limit as parameters but taking them out doesn't help either.

and this is my c# method

public string getRecords(string State, string ID, int start, int limit)

Solution

  • Have you tried this?

    this.myStore = Ext.create('Ext.data.Store', {
        scope: this,
        storeId: 'myStore',
        fields: [
            { name: 'State', type: 'string' },
            { name: 'ID', type: 'string' }
        ],
        proxy: {
            type: 'ajax',
            scope: this,
            extraParams: { State: '', ID: '' },
            url: 'myControl/getRecords',
            reader: {
                type: 'json',
                totalProperty: 'count',
                root: 'data'
            }
        },
        autoLoad: true
    });
    

    Cause paging is done by the pagingbar so you wan't need set it by yourself. The way you done it will override the paging params provided by the store (pagingbar)

    Note that you can override your extraParam value by calling

    myStore.getProxy().setExtraParam('State', 'AnyValue');