如何在 Extjs 中使标签变灰

How to grey out label in Extjs

如何在 Extjs 中动态变灰标签。

Ext.create('Ext.form.Panel', {
    title: 'Basic Form',
    renderTo: Ext.getBody(),
    bodyPadding: 5,
    width: 350,

    items: [,
    {
        xtype: 'label',
        text: 'Field2'
    },{
        xtype: 'textfield',
        fieldLabel: 'Field',
        name: 'theField'
    },
    {
        xtype: 'textfield',
        fieldLabel: 'Field2',
        name: 'theField2'
    }],

    buttons: [{
        text: 'Submit',
        handler: function() {

            var form = this.up('form').getForm();

            form.getFields().each(function(item){
                    item.setDisabled(true);
            });
        }
    }]
});

在上面的代码中,单击提交按钮后,我可以禁用文本文件及其标签。

我需要模仿标签的相同功能。我怎样才能在 Extjs 中做到这一点。

https://fiddle.sencha.com/#fiddle/1bn5

您可以在 Chrome 的调试器 "Elements" 选项卡中查看元素的样式。在您喜欢的主题 Triton 中,您会看到字段标签的样式为 opacity:0.3。现在您可以继续将此样式也添加到标签中:

this.up('form').down('label').setStyle('opacity', 0.3);