1

tl/dr: There is not any setter for labelStyle. So how can I change it's value on a function?

I've a afterrender listener and aim to set color of fieldLabel as white and set a emptyText instead of fieldLabel and meanwhile I need to change fieldLabel color to be white! So I need to access current component's lableStyle property. I've try to go within config but couldn't find it. As well tried to use Ext.apply() to set a property for related combo but this is not work either.

How can I achieve my aim over here?

//Related component `listeners`;
listeners   : {
        afterrender: 'removeLabel',
        focusenter: 'createLabel'
    },

//Related function;
removeLabel: function () {
        let formComponent = ['foocombobox', 'bartextfield', 'zetdatefield'];

        Ext.each(formComponent, function (eachComp) {
            let currentComp = Ext.ComponentQuery.query(eachComp)[0];

            if (currentComp.value === '')) {
                let currentLabel = currentComp.fieldLabel;
                currentComp.setEmptyText(currentLabel);

                //This can not work because of I've reach constructor config. So how can I reach?
                //currentComp.labelStyle  = "color:red;";

                //I tried to manipulate through Ext.apply but did not effect;
                //Ext.apply(currentComp, {labelStyle: "color:red;"});


            }
        });
    }, 
Nuri Engin
  • 813
  • 10
  • 38
  • Possible duplicate of [Extjs How can I change the 'style' of Ext.form.Label](https://stackoverflow.com/questions/24036429/extjs-how-can-i-change-the-style-of-ext-form-label) – Akrion Sep 24 '18 at 22:22

1 Answers1

2

I get dom node by currentComp.labelTextEl.dom and then run setAttribute function:

FIDDLE

if (!currentComp.value) {
    urrentComp.setEmptyText(currentComp.fieldLabel);
    currentComp.labelTextEl.dom.setAttribute('style', 'color:white;'); 
}
beso9595
  • 1,146
  • 3
  • 10
  • 16