2

我正在尝试在面板中实现本地化,因此为了使 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”

4

1 回答 1

0

您应该在函数中定义您的 items 数组initComponent,而不是作为数组属性。当您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);
        }    
于 2012-10-29T22:56:34.130 回答