ExtJS: dynamically changing element styles

I am trying to dynamically assign styles to my elements (in this case ExtJS displayfield).

I can’t use CSS classes since I don’t know what the colors will be before execution.

I'm trying to:

myDisplayField.getEl().applyStyles({ color: '#ff0000' });  //fail
myDisplayField.getEl().setStyle('color', '#ff0000');       //fail

Just to get the mechanism right, but none of them work.

It works using Ext.get(<div id>).setStyle(...), but for me it doesn't seem as clean. Is there a reason previous attempts fail?

What am I missing? Thanks.

+4
source share
1 answer

: . , , DOM , , ( div ) . field.getEl() ; top <table>. .

, DOM, , <div>, , displayfield-123-inputEl. -inputEl - ; , Ext.dom.Element . field.inputEl , , DOM. :

myDisplayField.inputEl.setStyle(...)

:

myDisplayField.setFieldStyle(...)

, CSS. , , .. CSS , , - , , - .

+6

All Articles