所以我panel
(可以称之为fooPanel
)含有grid
(让我们称之为如果fooGrid
,其中有一些store
)。 fooPanel
可以插入一些tabpanel
。所以问题是,tabpanel
可能包含两个(或更多)fooPanel
的实例,并带有一些不同的参数。我认为这个问题很明显。因为面板上的fooGrids
具有相同的stores
,只要我重新加载一个商店,两个fooGrids
正在重新加载。 (因为他们有相同的stores
)。有针对这个的解决方法吗?或者我应该限制用户只打开一个fooPanel
的实例,每tabpanel
问题与同一家商店格Ext JS的
3
A
回答
7
除了每个网格创建一个商店之外,没有简单的解决方案。如果您不想创建商店的多个实例的原因是为了避免多次加载,您可以在代理级别上进行某种缓存。
编辑如何创建多个商店为您的网格实例
您可以创建存储实例(即使用Ext.create('My.Store')
)你自己在你的initComponent
方法电网:
Ext.define('My.Store', {
extend: 'Ext.data.Store'
,fields: ['name']
,proxy: {
type: 'memory'
,reader: 'array'
}
,data: [['Foo'],['Bar'],['Baz']]
});
Ext.define('My.Grid', {
extend: 'Ext.grid.Panel'
,columns: [{dataIndex: 'name'}]
,initComponent: function() {
// /!\ Do that BEFORE calling parent method
if (!this.store) {
this.store = Ext.create('My.Store');
}
// ... but don't forget to call parent method
this.callParent(arguments);
}
});
// Then I can create multiple grids, they will have their own store instances
Ext.create('My.Grid', {
renderTo: Ext.getBody()
,height: 200
});
Ext.create('My.Grid', {
renderTo: Ext.getBody()
,height: 200
});
或者你可以在创建时指定新的商店实例:
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody()
,height: 200
,columns: [{dataIndex: 'name'}]
,store: Ext.create('My.Store') // one instance
});
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody()
,height: 200
,columns: [{dataIndex: 'name'}]
,store: Ext.create('My.Store') // two instances!
});
但是,就我而言,我通常不打算创建完整的商店定义。我在模型中配置代理,并使用该模型使用内联存储配置(内联配置将转换为它们自己的实例,在Ext4中)。例如:
Ext.define('My.Grid', {
extend: 'Ext.grid.Panel'
,columns: [{dataIndex: 'name'}]
// inline store configuration
,store: {
// The model takes care of the fields & proxy definition
model: 'My.Model'
// other params (like remoteSort, etc.)
}
});
// Now I can create plenty of My.Grid again, that won't interfere with each other
1
这篇文章可以帮助你
Ext.define('App.store.MyStore', {
extend : 'Ext.data.Store',
alias : 'store.app-mystore', // create store alias
// ...
});
Ext.define('App.view.MyCombo', {
extend : 'Ext.form.field.ComboBox',
xtype : 'app-mycombo',
requires : [
'App.store.myStore'
],
// combo config
store : {
type : 'app-mystore' // store alias; type creates new instance
}
});
1
在ExtJS的5,你可以采取的连锁店的优势。这样,您可以拥有一个源存储,而其他商店则使用不同的过滤器查看同一商店。
http://docs.sencha.com/extjs/5.0.0/whats_new/5.0/whats_new.html
相关问题
- 1. 的Ext JS 4:多个网格显示来自同一家商店
- 2. Ext JS 4 - 共享相同商店的网格实例
- 3. 超过200家商店与多商店和相同的产品?
- 4. Ext JS商店和复杂对象
- 5. 煎茶EXT-JS 4:如何在商店
- 6. Ext JS的网格selModel电网的商店更新
- 7. Extjs问题与商店
- 8. Azman与多家商店
- 9. Ext JS - 使用筛选器预配置网格商店
- 10. Ext JS加载店
- 11. Exp:resso商店一般问题
- 12. EXT JS网格SelModel复选框问题
- 13. 店面上的Ext js autoDestroy
- 14. 如何等待另一家商店在一家商店发生的调度
- 15. 贝宝与多家商家的网上商店
- 16. 可能Ext JS使用商店没有附加到网格呈现网格列?
- 17. 如何将商店注入到mobX的另一家商店
- 18. Ext JS范围问题
- 19. Ext JS -DOM查询问题
- 20. Ext JS舍入问题
- 21. Ext JS范围问题
- 22. 2与同一商店的TreePanel?
- 23. Google Play商店布局。问题与apktool
- 24. Sencha触摸问题与商店
- 25. 刷新未连接到商店的Ext JS面板?
- 26. 商店中未定义的变量:[]和视图:[] - Ext-JS 4.1.1a
- 27. Ext JS - 克隆进出商店的最佳方式是什么?
- 28. 刷新JSON商店的每60秒 - EXT JS 4
- 29. 如何映射/ URL/{} pathvariables到Ext JS的商店
- 30. Ext JS:将变量分配给商店中的数据
是否有你需要更多的情况下,任何的理由?如果是这样,只需更改每个实例的商店 – sra
是的,这是有原因的。我如何'为每个实例更改商店'? – Dimitri