vendredi 19 septembre 2014

How to bind/use a variables created in configuration.

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:



Code:



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:



Code:



...
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... duuhhh.

From the controller, that calls "myView":



Code:



...

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:


Code:



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






How to bind/use a variables created in configuration.

Aucun commentaire:

Enregistrer un commentaire