PDA

View Full Version : How to bind/use a variables created in configuration.



jesus.valencia
19 Sep 2014, 3:35 PM
Hello experts,

I am new to ExtJS, so maybe these things are simple, but I am struggling with this one:

I created a view (MVC) and created variables in its config, something like this:


Ext.define('myView', {
extend: 'Ext.window.Window',

config : {
label : 'xxx',
day : 'day',
month : 'month',
history : 'hist'

}


I need to use these values, in the UI Components of the view. This view is multipurpose, so it's called from different parts of the application and need to show different values, depending from where it's been called, so I thought I could achieve reusability, but I can't seem to map/bind these variables.

So far I have been trying these inside the initComponent method of the view:

...
items: [
{
xtype : 'displayfield',
name : 'label'
},{
xtype : 'displayfield',
name : '{day}'
},{
xtype : 'displayfield',
name : '{this.getMonth()}'
},{
xtype : 'displayfield',
name : '{this.history}'
}
]
...




When I create this view from the controller, I pass these parameters and the console shows the passed values correctly, I just can't seem to know how to use them... 8-| duuhhh.

From the controller, that calls "myView":


...

var label = "hola";
var day = 30;
var month = 87;
var history = 210;
var view = new myView({label:'test',day:'1',month:'12',history:'123'});
console.log("Label: " + view.getLabel());
...


Also, in "myView" at the end of the initComponent method I have this line:

console.log("Label: " + this.getLabel());

The console shows the values passed from the controller, if I don't send anything, it shows the default values fron de config.

Any comment or advise is welcome, thanks in advance.

JV

jesus.valencia
19 Sep 2014, 4:16 PM
Added the value property and now works.


{
xtype : 'displayfield',
name : 'history',
value : this.getHistory()
}