josei josei - 1 month ago 6
Javascript Question

Change date color e format date in same field

To format the date in a displayfield I use:

renderer: Ext.util.Format.dateRenderer('d-m-Y')


To change the date displayed color I use, for example:

renderer : function(val) {
if (val) {
return '<span style="color:' + '#CC6666' + ';">' + val + '</span>';
}
return val;
}


My problem is to use both simultaneously: the formatted date and change the color of the displayed date.

How to do this?

FIDDLE: https://fiddle.sencha.com/#fiddle/1jnj

Answer

Make a call to the formatter method:

renderer: function(val) {
    if (val) {
        return '<span style="color:#CC6666;">' + Ext.util.Format.date(val, 'd-m-Y') + '</span>';
    }
    return val;
}
Comments