在extjs中http发布时的分页参数

时间:2013-10-07 19:17:25

标签: extjs extjs4.2

您好我正在使用具有分页的extjs屏幕,并且请求中使用的方法必须通过HTTP POST动词响应。

我配置了我的商店,所以所有的阅读电话都是帖子。意识到,extjs只是传递请求有效负载的查询字符串,我认为可以将参数分开,就像它使用商店的params加载一样。

所以我想知道是否有可能在请求有效负载中使用{params:{start:0,page:1,limit:20}}而不是查询字符串start = 0& page = 1&限制= 20。

我使用Extjs 4.2和Java和RESTEasy。

1 个答案:

答案 0 :(得分:0)

没有任何内置功能,但您可以使用以下内容扩展商店的代理:

Ext.define('Ext.ux.proxy.ModifiedAjax', {
    extend: 'Ext.data.proxy.Ajax',
    alias: 'proxy.modifiedajax',

    defaultParams: 'param',
    removeDefaultParams: true,

    buildRequest: function(operation) {
        var me = this,
            request,
            defaultParams = me.getParams(operation);

        me.extraParams = me.extraParams || {};
        if (me.defaultParams && defaultParams) {
            me.extraParams[me.defaultParams] = me.applyEncoding(defaultParams);
        }

        var params = operation.params = Ext.apply({}, operation.params, me.extraParams);
        if (me.removeDefaultParams != true) {
            Ext.applyIf(params, defaultParams);
        }

        request = new Ext.data.Request({
            params   : params,
            action   : operation.action,
            records  : operation.records,
            operation: operation,
            url      : operation.url,
            proxy: me
        });
        request.url = me.buildUrl(request);
        operation.request = request;

        return request;
    }
});

在商店中,您需要将代理type设置为'modifiedajax'