PDA

View Full Version : Using class properties for field labels in view



oana0211
4 Jun 2013, 12:11 AM
Hello,

I have a question about using string class properties for some fields in my view.

I have this view in my app:


Ext.define('testApp.view.Main', {
extend: 'Ext.container.Container',
requires:[
'Ext.tab.Panel',
'Ext.layout.container.Border'
],

config: {
label1:'Custom title string'
},


xtype: 'app-main',


layout: {
type: 'border'
},


items: [{
region: 'west',
xtype: 'panel',
title: this.label1,
width: 150
},{
region: 'center',
xtype: 'tabpanel',
items:[{
title: 'Center Tab 1'
}]
}]
});


When rendering this page, the title of the first item is not rendered. I want to know if there is any possibility to make this work, without having to use Ext.apply() in the initComponent() function of the view.
I want to use this approach for localization of custom strings throughout my application.

Thanks.

evant
4 Jun 2013, 4:24 AM
You need to do it inside initComponent:



Ext.define('X', {
someProp: 'a',
initComponent: function(){
this.items = {title: this.someProp};
this.callParent();
}
});