2

设想

我有一个网格面板(比如网格),它在我的应用程序中随处使用。假设组件(面板 1面板 2)正在使用网格。这个网格正在使用存储(存储1)。我想更新面板 1 中的网格而不更新网格在面板 2 中

我的问题

不想在 panel1 和 panel2 中为网格使用不同的商店。他们有什么办法可以做到这一点。

我尝试将存储(使用新数据)绑定到 panel1 中的网格。但是 panel1 和 panel2 中的网格都在更新。

如果我不够清楚,请告诉我。请帮我解决这个问题。非常感谢。

**For reference**
/*my grid*/
Ext.define('APP.view.mygrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygrid',
store:'store1',
columns: [ ...  ]


/*my panels*/
{
  xtype:'panel',
  items:[
         {
           xtype :'mygrid',
         }
       ],
  xtype:'panel',
  items:[
         {
           xtype :'mygrid',
         }
        ],
 }
4

3 回答 3

0

我假设您通过商店中的一些本地更改来更新您的网格,并且您没有调用您的 Web 服务。然后你可以尝试这样做:

store.suspendEvents(false); // false: do not queue events
// do some data changes now
store.resumeEvents();

grid.getView().refresh(); // only on the first grid
于 2013-06-30T18:57:07.447 回答
0

每次调用网格时,我都通过创建商店的实例解决了这个问题。请看一下:

initComponent   : function() {
    this.items = [          
        {
            xtype   : 'myPanelgrids'
            name    : 'panel1' // this is the extra config to identify the grid in added in my panel1
        }

    ];
    this.callParent();
},
listeners: {
    render: function(){
        var store = Ext.create('Ext.data.Store', 
            {
                model: 'App.model.MyModel',
                autoLoad: true,
                 proxy: {
                        type: 'ajax',
                        url:'app/data/configdata.json',
                        reader: {
                            type: 'json',
                            root : 'myroot'//maintained a json property file with different roots for grids in panel1 and panel2
                        }
                    }
            }
        );

        this.down('grid').reconfigure(store);
    }
}

我正在从我的控制器更新特定网格的存储。

于 2013-07-02T04:48:32.737 回答
0

你可以为你的第二个面板创建商店,所以试试这个:

var secondStore=Ext.create('your_store');
items: [
    {
        xtype: 'gridpanel',
        title: 'grid1',
        store: 'your_store'
    },{
        xtype: 'gridpanel',
        title: 'grid2',
        store: secondStore
    }
]
于 2013-06-30T08:13:00.190 回答