Ext JS 4 - 如何创建多个商店实例并分配给视图? (MVC)
如何创建商店的唯一实例并将它们分配给视图(如果需要,我可以创建唯一的视图和/或控制器)?
一个简单的用例 - 我想打开多个网格(同一类型),每个网格中都有来自商店的记录列表。每个网格都需要有它自己的存储实例,因为它可能有它自己的记录列表,它自己的过滤等等。
我尝试了这个,但它不起作用,我的网格不绘制:
var theView = Ext.create('App.view.encounter.List');
theView.title = 'WORC Encounters';
var theStore=Ext.create('App.store.Encounters');
theView.store=theStore;
tabhost.add({title:'WORC',items:theView});
var theView = Ext.create('App.view.encounter.List');
theView.title = 'NC Encounters';
var theStore2=Ext.create('App.store.Encounters');
theView.store=theStore2;
tabhost.add({title:'NC',items:theView});
How do you create unique instances of stores and assign them to views (I am ok with creating unique views and/or controllers if that's required)?
A simple use case - I want to open multiple grid's (of the same type) with a list of records from a store in each. Each grid would need to have it's own store instance, because it could have it's own list of records, it's own filtering, etc. etc.
I tried this, but it does not work, my grids do not draw:
var theView = Ext.create('App.view.encounter.List');
theView.title = 'WORC Encounters';
var theStore=Ext.create('App.store.Encounters');
theView.store=theStore;
tabhost.add({title:'WORC',items:theView});
var theView = Ext.create('App.view.encounter.List');
theView.title = 'NC Encounters';
var theStore2=Ext.create('App.store.Encounters');
theView.store=theStore2;
tabhost.add({title:'NC',items:theView});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在组件初始化时(或之前)分配存储。在 initComponent.
您也可以这样做:
为您特定的示例进行编辑:
You need to assign the store when the component is initializing (or before). In the initComponent.
You could also do it this way:
Edit for you example specific: