簡體   English   中英

ExtJS4更改數據存儲參數

[英]ExtJS4 Changing data store parameters

如果我在網格上有一個數據存儲,如下所示:

store = Ext.create('Ext.data.Store', {
    fields: [{
        name: 'id'
    }, {
        name: 'filename'
    }
    // other fields here ...
    ],
    proxy: {
        type: 'ajax',
        url: 'http://myniftyurl.com/blah',
        simpleSortMode: true,
        reader: {
            type: 'json',
            totalProperty: 'total',
            root: 'result'
        },
        extraParams: {
            'limit': Ext.get('itemsPerPage').getValue(),
                'to': Ext.get('to_date').getValue()
            //  other params
        }
    },
    model: 'Page',
    remoteFilter: true,
    remoteSort: true
});

“限制”和“到”值將根據用戶輸入而改變,其中存在問題。 數據存儲使用原始參數而不是新輸入。 我怎樣才能解決這個問題?

提前致謝!

我通常通過在控制器中執行store.load()手動加載我的網格。

在那之前,我可以像這樣更改商店的參數:

//getForm() retrieves the Ext.basic.Form (from Ext.panel.Form)
var params = this.getForm().getValues();

//Write over
grid.getStore().getProxy().extraParams = params;

//load
grid.getStore().load();

我正在使用緩沖網格,需要大量的返工才能在4.0.7中完全正常工作。 但這應該對你有用。

另一個選擇是使用beforeload監聽器,但我不確定那時更改extraParams是否會做任何事情。 您可以修改傳遞給事件處理程序的Ext.data.Operation對象嗎?

讓我知道這對你有什么影響。

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM