Wednesday, 2 May 2012

Setting background color and font display color dynamically for LabelField in Extjs

We can set colors for LabelField dynamically in Extjs by use of the function setText().
Example :


 var test = new Ext.form.LabelField({
id: 'name',
                fieldLabel:'Name',
                width: 200,              
                height: 100,
                xtype: 'label',
});


normally it displays like these



in runtime you dynamically apply colors for "back -ground"  and "fonts" use these field id

Ext.getCmp('name').setText('<span id="ot" style="back-ground:yellow;color: red; display: block"><center><b>Welcome to My Blogspot </b></center></span>',false);
In runtime it shows




The false argument will prevent the html tags from being mangled by the function.


you can apply all HTML tags inside of these function

No comments:

Post a Comment