问题描述
我无法在控制器中获取组合框值.组合框视图的getter方法返回
I am not able to get combobox value in a controller. The getter method of combobox view returns
function i(){
return this.constructor.apply(this,arguments)||null
}
代替视图对象实例.如果我使用
instead of view object instance. If I use
var combo=this.getColumnTypeComboView().create()
然后我没有获得组合框combo.getValue()
的选定值.
then I don't get selected value of the combobox combo.getValue()
.
推荐答案
要在控制器中获取视图引用,只需使用 getView()方法.要在视图和控制器之间创建连接,请确保遵循MVC应用架构主体,找到此处
To get view reference in a controller simply use getView() method from the Controller class. To create a connection between view and a controller make sure that you follow MVC aplication architecture principals, found here
var view = this.getView('Contact'); //=> getView( name ) : Ext.Base
如果组合框是由您的控制器负责的视图项,则使用控制方法也来自Controller类.
if a combobox is a item of a view that your controller is in charge off, then use control method also from Controller class.
Ext.define('My.controller.Contact', {
extend: 'Ext.app.Controller',
views: ['Contact'],
init: function() {
//reference the view
var view = this.getView('Contact');
//reference the combobox change event
this.control({
'mywin combobox': {
change: this.onChangeContinent
}
});
},
onChangeContinent:function (field, value, options) {
//here you can get combobox component and its value
Ext.Msg.alert('Continent', value);
}
});
这是一个小提琴示例
here is a fiddle example
要从另一个组件引用一个组件,可以使用Controller ref 方法,如下所示:
To reference one component from another, you can use Controller ref method, like this:
refs: [{
ref: 'combo',
selector: 'mywin combobox'
}]
这篇关于在Controller EXTJS 4中查看参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!