Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为单个网格实例使用单个数据存储,这在extjs中随处可见_Extjs_Extjs4_Extjs4.2 - Fatal编程技术网

为单个网格实例使用单个数据存储,这在extjs中随处可见

为单个网格实例使用单个数据存储,这在extjs中随处可见,extjs,extjs4,extjs4.2,Extjs,Extjs4,Extjs4.2,场景 我有一个gridpanel(比如说,grid),它在我的应用程序中无处不在。假设组件(panel1和panel2)正在使用grid。这个grid正在使用一个存储(store1)。我想更新panel1中的网格,而不更新panel2中的网格 我的问题 我不想对panel1和panel2中的网格使用不同的存储。 他们有什么办法可以做到这一点 我尝试将存储区(使用新数据)绑定到panel1中的网格。但panel1和panel2中的网格都在更新 如果我不够清楚,请让我知道。请帮我解决这个问题。太多了

场景

我有一个gridpanel(比如说,grid),它在我的应用程序中无处不在。假设组件(panel1panel2)正在使用grid。这个grid正在使用一个存储(store1)。我想更新panel1中的网格,而不更新panel2中的网格

我的问题

我不想对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',
         }
        ],
 }

您可以为第二个面板创建存储,因此请尝试以下操作:

var secondStore=Ext.create('your_store');
items: [
    {
        xtype: 'gridpanel',
        title: 'grid1',
        store: 'your_store'
    },{
        xtype: 'gridpanel',
        title: 'grid2',
        store: secondStore
    }
]

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

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

grid.getView().refresh(); // only on the first grid
我已经解决了这一问题,每次 网格被调用。请查看:

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


谢谢。请查看我的编辑(供参考)。我想用不同的数据更新第一个面板中的网格,但第二个面板中的网格也会更新。尝试创建两个网格,grid1与store1和Grid2与store2。我已经编辑了AnswerThank@Christoph。我通过每次在组件(网格)初始化期间创建一个存储来解决这个问题。
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);
    }
}