Ext JS 4 - 理解 this.control、选择器和事件处理
我试图了解 Ext JS 4 (MVC) 中按钮、组合框和类似事件处理的工作原理。
具体来说,我相信在 MVC 中我们应该在控制器 init 函数中使用“this.control”。
例如,我有以下工作:
this.control({
'eventlist': {
itemdblclick: this.eventRowClicked
},
'eventedit button[action=save]': {
click: this.updateEvent
}
});
看起来很简单,我选择“事件列表”视图并为网格注册 eventRowClicked 事件。然后,在我的“eventedit”视图中,捕获按钮单击(保存按钮)。
接下来我需要的是响应组合框选择或更改事件。我认为有多个组合框,因此我需要一个特定的组合框。
我尝试了这个,但它不起作用(我也尝试选择而不是更改):
'eventedit dispositionpop': {
change: function(combo, ewVal, oldVal) {
debugger;
}
}
我能找到的所有示例都不使用“this.control”,它们要么将组件(Ext.get?)抓取到变量中,或类似的。我相信这些方法不是正确的 mvc - 或者可能不是 Ext JS 4 最有效的方法。
所以我想知道两件事 - 我如何注册特定的组合框选择或更改事件,以及我可以读取什么更好地理解 this.control 中发生的事情 - 例如,那些是 css 选择器吗?
I am trying to understand in Ext JS 4 (MVC) how event handling on buttons, comboboxes and similar work.
Specifically, I believe in MVC we are supposed to be using "this.control" in the controller init function.
For example, I have the following working:
this.control({
'eventlist': {
itemdblclick: this.eventRowClicked
},
'eventedit button[action=save]': {
click: this.updateEvent
}
});
Seems straightforward, I am selecting the 'eventlist' view and registering for an eventRowClicked event for the grid. Then, in my 'eventedit' view, trapping for a button click (the save button).
What I need next, is to respond to a combobox select or change event. I have multiple comboboxes in my view, so I need a specific one.
I tried this, but it did not work (I also tried select instead of change):
'eventedit dispositionpop': {
change: function(combo, ewVal, oldVal) {
debugger;
}
}
All the examples I can find do not use 'this.control', they either grab the component (Ext.get?) in to a variable, or similar. I believe those methods are not proper mvc - or possibly not the most efficient way for Ext JS 4.
So the two things I want to know - how would I register for a specific combo box select or change event, and what can I read to better understand what is happening in this.control - for example, are those css selectors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些不是 css 选择器,但它们就像 css 选择器。让我们看一下这样一个简单的例子。您的一个视图具有这样的结构:
现在您可以使用三种方式通过
control
为该视图分配处理程序:way No1
最糟糕的一种 - 使用 id:
way No2
使用 xtype:
way No3
使用配置属性:
当然,你可以像 fi 组合 xtype 和 config 属性一样组合它们:
用空格和
>
分隔选择器与 css 中的含义相同。对于您的示例,最好的方法是 No3 或组合 xtype 和 config 属性的方法。
Those are not css selectors but they are like css selectors. Let's take a look at such simple example. One of your views has such a structure:
Now you can assign handlers via
control
for this view using three ways:way No1
The worst one - using id:
way No2
Using xtype:
way No3
Using config property:
And of course you can combine them like f.i. combine xtype and config property:
Separating selectors with whitespace and
>
has the same meaning as in css.For your example the best way would be the way No3 or combining xtype and config property.