2

ページングツールバーを機能させるのに問題があります。初期ロードは「start」および「limit」パラメーターをサーバープロキシに渡し、データはグリッドに正常にロードされます。ただし、ページングツールバーの[次へ]ボタンをクリックすると、[開始]パラメーターと[制限]パラメーターが正しく渡されず、Webメソッドはこれらのパラメーターを予期しているために爆発します。あなたが私が根本的な問題を解決するのを手伝ってくれるなら、それは素晴らしいでしょう。しかし、そうでない場合、そしてあなたが私がボタンをオーバーライドするのを手伝ってくれるなら、それも問題ないので、何が悪いのかがわかるまで一時的な修正を加えることができます。

例外:

POST http://{domain}/Controls/ObjectList/ObjectListService.asmx/GetObjectList?_dc=1348591244365 500 (Internal Server Error) ext-all-debug.js:36837
Ext.define.request                  ext-all-debug.js:36837
Ext.define.doRequest                ext-all-debug.js:49508
Ext.define.read                     ext-all-debug.js:39082
Ext.define.load                     ext-all-debug.js:47668
Base.implement.callParent           ext-all-debug.js:3728
Ext.define.load                     ext-all-debug.js:50160
Ext.define.read                     ext-all-debug.js:47399
Ext.define.loadPage                 ext-all-debug.js:50404
Ext.define.nextPage                 ext-all-debug.js:50409
Ext.define.moveNext                 ext-all-debug.js:102105
Ext.define.fireHandler              ext-all-debug.js:79530
Ext.define.onClick                  ext-all-debug.js:79520
(anonymous function)
Ext.apply.createListenerWrap.wrap   ext-all-debug.js:9171

{"Message":"Invalid web service call, missing value for parameter: \u0027query\u0027.","StackTrace":"   at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}

===========================

ソースコード:

    var itemsPerPage = 30;

    var store = new Ext.data.Store({
        proxy: new Ext.ux.AspWebAjaxProxy({
            url: '/Controls/ObjectList/ObjectListService.asmx/GetObjectList',
            actionMethods: {
                create: 'POST',
                destroy: 'DELETE',
                read: 'POST',
                update: 'POST'
            },
            reader: {
                type: 'json',
                model: 'Object',
                totalProperty: 'd.recordCount',
                //idProperty: 'object_id',
                root: 'd.resultSet'
            },
            headers: {
                'Content-Type': 'application/json; charset=utf-8'
            }
        }),
        pageSize: itemsPerPage,
        noCache: false,
        //autoLoad: true
        autoLoad: {
            params: {
                //query: '',
                start: 0,
                limit: itemsPerPage
            }
        }
    });    

...

    Ext.define('ObjectGrid', {
        extend: 'Ext.grid.Panel',

        initComponent: function () {
            var me = this;

            Ext.applyIf(me, {
                store: store,
                forceFit: true,
                autoScroll: true,
                height: 750,
                loadMask: true,

                columns: [
                ],

... 

                bbar: Ext.create('Ext.PagingToolbar', {
                    store: store,
                    displayInfo: true,
                    pageSize: 30,
                    displayMsg: 'Displaying records {0} - {1} of {2}',
                    emptyMsg: 'No records to display'

//                    type: 'pagingmemory',

//                    listeners: {
//                        afterrender: {
//                            single: true,
//                            fn: function (thispaging) {
//                                thispaging.first.on('click', function () {
//                                    Ext.Msg.alert('first', 'first');
//                                });
//                                thispaging.prev.on('click', function () {
//                                    Ext.Msg.alert('prev', 'prev');
//                                });
//                                thispaging.next.on('click', function () {
//                                    Ext.Msg.alert('next', 'next');
//                                });
//                                thispaging.last.on('click', function () {
//                                    Ext.Msg.alert('last', 'last');
//                                });
//                            }
//                        }
//                    }


//                    listeners: {
//                        'click' : function(which) { 
//                            alert('you have clicked'); 
//                        } 
//                    } 

                })  // bbar

            });

            me.callParent(arguments);
        }
    });

アップデート#1:

上記のスタックトレースでは、これら2つの呼び出しの間でパラメーターが失われています。

ここに画像の説明を入力してください

39082行目:

this.requests.5.options.params = "{}"
(5) being the current object

ここに画像の説明を入力してください

47668行目:

operation.start = 2
operation.limit = 30

ここに画像の説明を入力してください

アップデート#2:

Ext.define('Ext.ux.AspWebAjaxProxy', {
    extend: 'Ext.data.proxy.Ajax',
    require: 'Ext.data',
    //processData: false,

    buildRequest: function (operation) {
        var params = Ext.applyIf(operation.params || {}, this.extraParams || {}),
                                request;
        params = Ext.applyIf(params, this.getParams(params, operation));
        if (operation.id && !params.id) {
            params.id = operation.id;
        }

        params = Ext.JSON.encode(params);

        request = Ext.create('Ext.data.Request', {
            params: params,
            action: operation.action,
            records: operation.records,
            operation: operation,
            url: operation.url
        });
        request.url = this.buildUrl(request);
        operation.request = request;
        return request;
    }
});
4

2 に答える 2

1

ExtJSバージョン4.0.0に戻ろうとしましたが、アプリケーションの他の機能が壊れています。だから私はバージョン4.1.0に固執し、このプロキシのハックを実装して動作するようにしました。そうすれば、ある程度の安心感を得ることができます(または「安心」ですか?)。

Ext.define('Ext.ux.AspWebAjaxProxy', {
    extend: 'Ext.data.proxy.Ajax',
    require: 'Ext.data',

    buildRequest: function (operation) {
        var params = Ext.applyIf(operation.params || {}, this.extraParams || {}),
                                request;
        params = Ext.applyIf(params, this.getParams(params, operation));

        if (params.page == null) {
            params.page = operation.page;
            params.start = operation.start;
            params.limit = operation.limit;
        }

        if (operation.id && !params.id) {
            params.id = operation.id;
        }

        params = Ext.JSON.encode(params);

        request = Ext.create('Ext.data.Request', {
            params: params,
            action: operation.action,
            records: operation.records,
            operation: operation,
            url: operation.url
        });
        request.url = this.buildUrl(request);
        operation.request = request;
        return request;
    }
});


//});
于 2012-09-26T00:47:46.287 に答える
1

まあ、トリックは中にあると思います

// Clone params right now so that they can be mutated at any point further down the call stack
var me = this,
    params = operation.params = Ext.apply({}, operation.params, me.extraParams),
    request;

これを使って最初の行を置き換えることができると思います。そうすればうまくいくはずです。

もご覧ください

// Set up the entity id parameter according to the configured name.
// This defaults to "id". But TreeStore has a "nodeParam" configuration which
// specifies the id parameter name of the node being loaded.
if (operation.id !== undefined && params[me.idParam] === undefined) {
    params[me.idParam] = operation.id;
}

これも更新する必要がある場合はわかりません。

于 2012-09-26T08:56:32.327 に答える