EXTJS GRID和商店

时间:2014-01-30 12:29:42

标签: javascript extjs

我有EXT JS 4.2网格和存储。

现在,一个页面加载网格从商店获取数据并在UI上显示。

我在页面上有日期下拉过滤器。在日期选择日期过滤器时,一个请求应该转到服务器从db获取数据并使用更新的数据重新加载存储,并且网格应该使用更新的存储值进行更新。

我的问题是如何解除退出存储从网格加载,使用日期设置存储参数,然后在存储中获取新数据并绑定到网格。并在网格上显示更新的数据?

提前致谢

这是创建网格的代码,在点击新的参数需要传递给服务器时创建一个按钮

{
                xtype: 'container',
                layout: 'hbox',
                style: 'margin-left: 152px;',
                width: 960,
                height: 'auto',
                cls: 'portlet full',
                items: Ext.getCmp('grid')

            }, {  //Create Button to fetch Grid Checked Data//
            xtype: 'container',
            layout: 'hbox',
            style: 'margin-left: 163px;padding-top: 20px;padding-bottom: 59px;',
            items: [
                    Ext.create('Ext.Button', {
                    name: 'Click me',
                    width:'40px',
                    handler: function() {

更新============================================= < / p>

        Ext.create('store', {storeId: 'storetest2'}).load({
        params: {
            // To send Extra Params
            'lastname':'test2'
        },
        callback: function(records, operation, success) {
            // To Perform some call back operations
        }
    });
    scndStore = Ext.data.StoreManager.lookup('storetest2'),
    Ext.getCmp('grid').reconfigure(scndStore);

更新============================================= < / p>

               })
         ],

2 个答案:

答案 0 :(得分:3)

  

将数据导入新商店后,您可以使用

grid.reconfigure(store, [columns])
  

更改绑定到网格的商店。请看一下docs

简单的工作fiddle

  

更新:试试这个

var store2 = Ext.create('Ext.data.Store', {
               model : 'store2Model',   //Don't miss to mention model 
               storeId: 'storetest2',
               proxy : {
                         type : 'ajax',
                         url  :'someUrl'
                         reader : {
                                    type : 'json',
                                    root : 'items' // depends 
                                   }
                        }
             });
 store2.load({
    params: {
        // To send Extra Params
        'lastname':'test2'
    },
    callback: function(records, operation, success) {
        grid = Ext.getCmp('grid'); //First check whether you are getting this comp properly
        grid.reconfigure(store2);
    }
});

答案 1 :(得分:0)

已修复this.getStore().load({ params: {test:'test1'},..我正在使用过滤器,我在第二次加载.this.getStore().clearFilter(true);之前没有清除它

相关问题