ExtJS 4即时更改网格存储 [英] ExtJS 4 Change grid store on the fly

查看:85
本文介绍了ExtJS 4即时更改网格存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,我有两个模型:



可以在ExtJS 4中更改网格的商店吗? pre> User = Ext.define('User',{
extends:'Ext.data.Model',
[...],
hasMany:'Product'
});

Product = Ext.define('Product',{
extends:'Ext.data.Model',
[...]
});

和两个网格。
第一个网格与Store使用 User 模型链接,并从后端加载嵌套的json数据,如

  {
users:[{
id:1,
products:[
{id:1},
{ id:2}
]
},{
id:2,
产品:[
{id:3},
{id:4} ,
{id:5}
]
}]
}

我想要得到的是当您单击第一个网格中的行时,第二个网格必须显示用户的产品,而不连接到服务器。
我知道的是 user.products(); 返回一个 Ext.data.Store 对象。
所以这个想法是将第二个网格的商店更改为 user.products(); ,但是没有这样的方法 grid.setStore谢谢提前

解决方案

我认为一个更好的解决方案是:

  grid1.on('itemclick',function(view,record ){
grid2.reconfigure(record.products());
);


Is it posible to change grid's store in ExtJS 4?

For example, i have two models:

User = Ext.define('User',{
  extend: 'Ext.data.Model',
  [...],
  hasMany: 'Product'
});

Product = Ext.define('Product',{
  extend: 'Ext.data.Model',
  [...]
});

and two grids. The first grid is linked with Store which uses User model and loads nested json data from backend, like

{
  users: [{
     id: 1,
     products: [
       {id: 1},
       {id: 2}
     ]
  }, {
     id: 2,
     products: [
       {id: 3},
       {id: 4},
       {id: 5}
     ]
  }]
}

All i want to get is when you click on the row in the first grid, the second grid must show products of the user, without connection to the server. All i know is that user.products(); returns a Ext.data.Store object. So the idea is to change second grid's store to user.products();, but there is no such method grid.setStore() :-)

Thanks in advance

解决方案

I think a better solution would be to :

     grid1.on('itemclick', function(view, record) {
         grid2.reconfigure(record.products());
     );

这篇关于ExtJS 4即时更改网格存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆