ExtJS 4 - 如何从 MVC 中的视图访问多个商店?
我正在尝试使用新的 MVC 方法在 extjs 4 中构建一个应用程序。 我有一个网格,用户可以在其中单击
一行并完成编辑Ext.window。
定义了带有选项卡的Ext.window
在控制器中作为视图。我遇到了两件事的问题:
1) 窗口有 2 个网格,我希望在单击选项卡时从商店填充这些网格。定义网格存储时,即使它在我的控制器中被拒绝,我也无法访问它。我尝试过
...
xtype:'grid',
store:MyApp.store.Products
columns:[..]
...
但没有运气!
还尝试为视图定义多个商店:
Ext.define('MyApp.view.Edit', {
extend:'Ext.window.Window',
store:['Products','Countries']
...
但也没有运气。如果我在视图中只定义了一个商店,我可以使用 this.Countries
来访问它。
2) 我的第二个问题部分相关。 Ext.window
是一个表单,其中填充了来自单击的网格行的数据。
如何使用推送到其中的数据填充 Ext.window 表单中的一个网格?默认情况下它应该有一个空存储,然后在 tabclick
上有一个侦听器吗?或者我可以将数据对象推入其中吗?
任何帮助表示赞赏。
I am trying to build a app in extjs 4 using the new MVC method approach.
I have a grid where the user can click
on a row and the editing is done Ext.window.
This Ext.window
with tabs is defined in the controller as a view. I am having problems with 2 things:
1) The window has 2 grids, which I would like to have populated from a store, when the tab is clicked. When defining the grid's store, I cannot access it even though it was denied in my controller. I tried
...
xtype:'grid',
store:MyApp.store.Products
columns:[..]
...
but no luck!
Also tried to define multiple stores for the view:
Ext.define('MyApp.view.Edit', {
extend:'Ext.window.Window',
store:['Products','Countries']
...
But also no luck. If I have only ONE store defined in the view, I can access it with this.Countries
for example.
2) My second question is partly related. The Ext.window
is a form getting populated with data from the grid row that was clicked.
How can I populate one of the grids in the Ext.window form with the data that was pushed to it? Should it have an empty store by default and then have a listener on the tabclick
? Or can I just push a data object into it?
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要回答您的第一个问题,您需要在控制器中引用您的商店。你可以在你的控制器中做这样的事情
To answer your first question, you need to reference your stores in the controller. You could do something like this in your controller