如何传递额外参数进行分页

问题描述 投票:0回答:2

我知道分页需要传递给控制器的启动和限制参数...但我还使用了更多需要传递的参数...即“STATE”和“ID”...我尝试了baseParams,params ...没有任何作用...这是我的商店

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
    });

我知道我不必使用 start 和 limit 作为参数,但将它们取出也没有帮助。

这是我的 C# 方法

public string getRecords(string State, string ID, int start, int limit)
c# asp.net-mvc-3 extjs parameters pagination
2个回答
2
投票

你尝试过这个吗?

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
});

因为分页是由分页栏完成的,所以你不需要自己设置它。您完成此操作的方式将覆盖商店提供的分页参数(分页栏)

请注意,您可以通过调用来覆盖 extraParam 值

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

0
投票

start是默认起始页,limit是每页的行数

 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,

                start:0,    
                limit: 25
            }
        },
        autoLoad: true
    });
© www.soinside.com 2019 - 2024. All rights reserved.