简体   繁体   English

ExtJS4更改数据存储参数

[英]ExtJS4 Changing data store parameters

If I have a data store on a grid like so: 如果我在网格上有一个数据存储,如下所示:

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

The 'limit' and 'to' value will change based on user input, therein lies the problem. “限制”和“到”值将根据用户输入而改变,其中存在问题。 The data store keeps using the original parameters instead of the new inputs. 数据存储使用原始参数而不是新输入。 How can I fix this? 我怎样才能解决这个问题?

Thanks in advance! 提前致谢!

I normally load my grids manually by executing the store.load() in the controller. 我通常通过在控制器中执行store.load()手动加载我的网格。

That way prior to it I can change the store's params like so: 在那之前,我可以像这样更改商店的参数:

//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();

I'm using buffered grids which required a decent amount of rework to get completely working in 4.0.7. 我正在使用缓冲网格,需要大量的返工才能在4.0.7中完全正常工作。 But that should work for you. 但这应该对你有用。

Another options is to use a beforeload listener but I'm not sure if changing the extraParams by then will do anything. 另一个选择是使用beforeload监听器,但我不确定那时更改extraParams是否会做任何事情。 You may be able to modified the Ext.data.Operation object that gets passed to the event handler? 您可以修改传递给事件处理程序的Ext.data.Operation对象吗?

Let me know how that works out for you. 让我知道这对你有什么影响。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM