0

ページネーションを使用して ExtJS からグリッド データ ビューを作成しようとしています。
実際、単純なデータ グリッドを作成する場合は問題ありません。
次に、Ext Form を使用して「フィルター/検索」機能を作成したいと考えています。
1ページ目だけの作業です。以下は私のExtフォームコードです:

var winFilter = Ext.create('widget.window',{
title   : 'Filter',
width  : 400,
height : 200,
modal  : true,
closeAction    : 'hide',
items  : frmFilter,
layout : 'fit',
bodyPadding: 5,
buttons:[
{
    text    : 'Filter',
    handler: function(btn){
        var win = btn.up('window');
        var form = win.down('form');
        tempProductID = form.getForm().findField('Product_ID').getSubmitValue();
        tempDescription = form.getForm().findField('Description').getSubmitValue();
        store.load({
            params: {
                start: 0,
                limit: itemsPerPage,
                productid: form.getForm().findField('Product_ID').getSubmitValue(),
                description: form.getForm().findField('Description').getSubmitValue()
            }
        });
        winFilter.hide();
    }
},
{
    text    : 'Close',
        handler: function(){
        winFilter.hide();
    }
}
]});

次のページでは、JSON は以前に使用したフィルター値 (製品 ID と説明) を使用せずにすべてのデータを返します。
アドバイスあればお願いします

ありがとうつぼみ。

4

1 に答える 1

1

params(メソッドの引数として使用される場合load) は 1 回だけ適用されます。これらのパラメーターを各リクエストに適用する場合は、proxy extraParamsプロパティを変更する必要があります。

Ext.apply(store.proxy.extraParams, {
    productid: form.getForm().findField('Product_ID').getSubmitValue(),
    description: form.getForm().findField('Description').getSubmitValue()
}, {});
store.load();

それ以外の場合は、storeフィルターメソッドを使用できます ( store.remoteFilterを true に設定する必要があります)。

store.filter([
    {property: "productid", value: form.getForm().findField('Product_ID').getSubmitValue()},
    {property: "description", value: form.getForm().findField('Description').getSubmitValue()
]);

ただし、filterアプローチを使用する場合、リクエスト URL のフィルター部分の形式が異なることに注意してください。この場合、フィルター部分は のようになり?filter=[{'property':'productid','value':2}]&limit=10...ます。一方、paramsアプローチが使用される場合、url は次のようになり?productid=2&limit=10...ます。したがって、filterアプローチが使用される場合、バックエンドはfilterリクエストのプロパティを解析する必要があります。

于 2013-07-19T10:35:55.313 に答える