View Help in the EXTJS 4 Controller

I can not get the combobox value in the controller. The getter method of the combobox view returns

function i(){ return this.constructor.apply(this,arguments)||null } 

instead of an instance of the viewer. If i use

 var combo=this.getColumnTypeComboView().create() 

then I do not get the selected value combobox combo.getValue() .

+6
source share
1 answer

To get a view link in the controller, simply use the getView () method from the Controller class. To create a connection between the view and the controller, make sure that you follow the principles of the MVC application architecture, here here

 var view = this.getView('Contact'); //=> getView( name ) : Ext.Base 

if combobox is a view element in which your controller is disabled, then use the control method also from the 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 an example script

EDIT:

To reference one component from another, you can use the Controller ref method, for example:

 refs: [{ ref: 'combo', selector: 'mywin combobox' }] 

here is an example script 2

+4
source

Source: https://habr.com/ru/post/948683/


All Articles