ExtJS - How can I color just a part of the text

时间:2016-08-31 16:50:41

标签: javascript html extjs

I use the setTitle inside a function for a dynamic title for my grid.panel and add variables to it.

Is there a way to color only the vars? For example, I want the ondevs to be green.

changeTitle: function(){
    var ondevs = 0;
    var offdevs = 0;
    this.getView().setTitle(Strings.dev + " - " + ondevs + " Online " + offdevs + " Offline");
}

Thanks!

1 个答案:

答案 0 :(得分:1)

You can just put any HTML you want into a panel header (panel, formpanel, gridpanel):

Ext.create('Ext.panel.Panel',{
    renderTo:Ext.getBody(),
    width:300,
    height:100,
    title:'<span style="color:springgreen">17</span> Online</u>'
});

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