javascript - EXTJS GRID 和存储

标签 javascript extjs

我有 EXT JS 4.2 Grid 和存储。

现在一个页面加载网格从存储中获取数据并显示在 UI 上。

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

我的问题是如何解除现有商店与网格加载的绑定(bind),设置带有日期的商店参数,然后在商店中获取新数据并绑定(bind)到网格。并在网格上显示更新的数据?

提前致谢

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

{
                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() {

更新=============================================

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

更新=============================================

               })
         ],

最佳答案

After getting data into the new store,you can use

grid.reconfigure(store, [columns])

to change which store is bound to the grid..Please have a look docs.

一个简单的工作fiddle

Update:Try this

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

关于javascript - EXTJS GRID 和存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21456598/

相关文章:

javascript - 如何从node js post ajax请求中读取数据?

javascript - 如何根据属性过滤对象数组?

javascript - Bootstrap : collapse-group within collapse-group

javascript - 如何在 javascript 中更改 "html"本身的 CSS 属性?

javascript - 如何在 ExtJS GridPanel 的列中居中放置图像?

javascript - setActiveItem() 传递数据 sencha touch

extjs - 如何循环遍历 extjs 网格对象以获取其元素和值

javascript - ExtJS -- 将 JSON 数据加载到树面板中

javascript - 如何将转换应用于 svg 路径元素?

javascript - 让 LocalStorageProxy 与 TreeStore 一起工作