PDA

View Full Version : Ext.getCmp('someid').setValue() : styling setValue parameter



won.rhee
17 Nov 2011, 1:21 PM
[RESOLVED]

Hello again,

I'm using Ext.getCmp('textfieldid').setValue('Current Locaton'); to change textfield in form panel.
I would like to simple style 'Current Location' with css markup.
Ext.getCmp('neartextfield').setValue("<div style='color:blue;'>CurrentLocation</div>"); Obviously does not work.
What could be a simple workaround?

AndreaCammarata
17 Nov 2011, 11:26 PM
You can apply a different css class to your textfield to make it appears with blue text color, by simply calling



myTextField.addCls('myBlueClass');


where "myBlueClass" is your custom css class.
Please also notice that is always better get a field by using the "getComponent()" function instead of using "getCmp()".

For istance:



myForm.getComponent('myTextField');


where "myTextField" is your textfield "itemId".

won.rhee
18 Nov 2011, 4:54 PM
thank you Andrea. it was very helpful.