Reputation: 129
I have a grid with grouping, following is the group titles definition:
xtype: 'gridpanel',
itemId: 'PRG_GRID',
layout: 'fit',
region: 'center',
store: 'PRGStore',
features: [
Ext.create('Ext.grid.feature.GroupingSummary', {
ftype: 'groupingsummary',
id: 'groupSummary',
groupHeaderTpl: '<br>  <font size="2" color="#4169E1"><b>' +
' {[values.name == 1 ? "Above 80%" : ' +
'[values.name == 2 ? "Above 50%" : ' +
'[values.name == 3 ? "Above 50%" : ' +
'[values.name == 4 ? "Notching" : ' +
'[values.name == 77 ? "Contracted" : ' +
'"TRASH"] ] ] ] ]} </b><br><br>',
startCollapsed: true
})
],
columns: {
...
and everything is working well but I want to display the last title "TRASH" in different color then #4169E1, e.g. in red. And I can't find the proper way to do it. Be so kind to help?
Upvotes: 0
Views: 381
Reputation: 1863
Use functions inside a template to simplify it and avoid duplication.
groupHeaderTpl: [
'{[this.styledHeader(values,parent)]}', {
styledHeader: function(values, parent) {
switch (values.name) {
case 1:
return this.wrapAnother("Above 80%");
case 2:
return this.wrapAnother("Above 50%");
case 3:
return this.wrapAnother("Above 50%");
case 4:
return this.wrapAnother("Notching");
case 77:
return this.wrapAnother("Contracted");
default:
return this.wrapTrash("TRASH");
}
},
wrapTrash: function(value) {
return this.wrapToFont('red', value);
},
wrapAnother: function(value) {
return this.wrapToFont('#4169E1', value);
},
wrapToFont: function(color, value) {
debugger
return '<font size="2" color="' + color + '">' + value + '</font>'
}
}
]
Upvotes: 2