我正在尝试在面板中实现Localization,所以要使fieldLabel可以从另一个文件访问,我就像这样定义它
Ext.define('Ext.app.detailForm', {
extend: 'Ext.form.Panel',
id: 'cscForm',
// frame: true, uncomment this to show blue frame background
title: 'CSC Details :',
//trying
cscCode: 'CSC Code',
bodyPadding: 5,
layout: 'anchor', // Specifies that the items will now be arranged in columns
autoScroll: true,
//width:1200,
//height: 300,
collapsible: true,
fieldDefaults: {
labelAlign: 'left',
msgTarget: 'side'
},
items: [{
columnWidth: 0.4,
xtype: 'container',
layout:'anchor',
defaults: {
labelWidth: 150
},
defaultType: 'textfield',
items: [{
xtype: 'container',
layout: 'hbox',
items:[{
xtype: 'fieldset',
columnWidth:1.5,
layout: 'column',
width:1050,
defaultType: 'textfield',
defaults: {
labelWidth: 150,
margin: '3 0 0 10'
},
items: [{
fieldLabel: this.cscCode,
name: 'CSCCode',
width: 500
}, {.....
但是当我尝试渲染这个面板时,cscCode的formLabel没有显示,我在这里做错了吗?
我基本上无法访问“this.cscCode”
答案 0 :(得分:0)
您应该在initComponent
函数中定义items数组,而不是数组属性。
在数组属性中定义this.cscCode
时,this
的范围有误。
Ext.define('Ext.app.detailForm', {
extend: 'Ext.form.Panel',
id: 'cscForm',
// frame: true, uncomment this to show blue frame background
title: 'CSC Details :',
//trying
cscCode: 'CSC Code',
bodyPadding: 5,
layout: 'anchor', // Specifies that the items will now be arranged in columns
autoScroll: true,
//width:1200,
//height: 300,
collapsible: true,
fieldDefaults: {
labelAlign: 'left',
msgTarget: 'side'
},
initComponent: function() {
this.items = [{
columnWidth: 0.4,
xtype: 'container',
layout:'anchor',
defaults: {
labelWidth: 150
},
defaultType: 'textfield',
items: [{
xtype: 'container',
layout: 'hbox',
items:[{ .....
items: [{
fieldLabel: this.cscCode,
name: 'CSCCode',
width: 500
}, {.....
}]
this.callParent(arguments);
}