【问题标题】:Extjs 4: grid duplicated in web interface same structure. Each grid has a different storeExtjs 4:网格在 Web 界面相同的结构中重复。每个网格都有不同的商店
【发布时间】:2014-06-21 19:55:58
【问题描述】:

我有一个包含多个网格的 Web 界面 每个网格具有相同的结构。 但是每个网格都由具有相同模型的不同商店填充。

Ext.define("erapnot.view.taskslist.EastItemSdPnGrid", {
  extend: "Ext.grid.Panel",
  xtype: "eastitemsdpngrid",
  store: "EastItemStore",
  columns:[...

我尝试为每个网格添加一个“id”,如下所示:

id:'east-panel',  
xtype: 'panel',
region:'east',
title: 'LIST',
items: [{ 
          id:'**firsteastitemgrid**',
          xtype: "eastitemgrid" 
       }, { 
          id:'**secondeastitemgrid**',
          xtype: "eastitemgrid" 
       }
       ]
},

所以我在我的网格中尝试了这个

Ext.define("erapnot.view.taskslist.EastItemGrid", {
  extend: "Ext.grid.Panel",
  xtype: "eastitemgrid",
  store:{"#firsteastitemgrid": "EastItemStore" , 
         "#secondeastitemgrid":"EastItemDifStore"},

我没有语法错误,但它不起作用。

是否可以使用多个商店只定义一次网格?或者,即使所有网格都具有相同的结构、模型、控制器,我也必须按商店创建一个网格。

提前致谢。

【问题讨论】:

  • 它们有什么不同?当然,您不会一遍又一遍地显示完全相同的网格和相同的内容。
  • 例如,所有网格内容“name”“firstname”。只有后端的 SQL 请求会检索到不同的结果,但所有网格都会显示一个包含“name”“firstname”列表的结果。
  • 对,但它如何检索不同的结果?我的观点是,改变的部分是什么。服务器不会随机返回不同的数据。
  • 除了我的 "proxy:{url: 'abc/cde'.... 在我的 store.js 文件中调用不同的 SQL 请求之外没有任何变化。

标签: grid structure store extjs4.2


【解决方案1】:

您的解决方案似乎很奇怪。尝试在实例化期间设置存储:

items: [{ 
      store:"EastItemStore",
      xtype: "eastitemgrid" 
   }, { 
      store:"EastItemDifStore",
      xtype: "eastitemgrid" 
   }]

并且在网格定义中不要设置任何存储。

【讨论】:

    【解决方案2】:

    做这样的事情:

    Ext.define('MyGrid', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.mygrid',
    
        columns: [],
    
        initComponent: function() {
            this.store = new Ext.data.Store({
                model: 'MyModel',
                proxy: {
                    type: 'ajax',
                    url: this.storeUrl
                    // other options here
                }
            });
            this.callParent();
        }
    });
    

    那你以后就可以用了:

    items: [{
        xtype: 'mygrid',
        storeUrl: '/foo/a'
    }, {
        xtype: 'mygrid',
        storeUrl: '/foo/b'
    }, {
        xtype: 'mygrid',
        storeUrl: '/foo/c'
    }]
    

    【讨论】:

      猜你喜欢
      • 2011-08-28
      • 1970-01-01
      • 2013-04-26
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 2014-02-11
      • 1970-01-01
      相关资源
      最近更新 更多