在Controller EXTJS 4中查看参考 [英] View Reference in Controller EXTJS 4

查看:71
本文介绍了在Controller EXTJS 4中查看参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在控制器中获取组合框值.组合框视图的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().

推荐答案

要在控制器中获取视图引用,只需使用

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

如果组合框是由您的控制器负责的视图项,则使用

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中查看参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆