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

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

问题描述

是否可以在 ExtJS 4 中更改网格的存储?

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

例如,我有两个模型:

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

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

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

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}
     ]
  }]
}

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

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

提前致谢

推荐答案

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

I think a better solution would be to :

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

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

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