When I try to change the text color of a date formatted field I end up with a blank
PeriodEndTemplate: function(field, data, column) {
var CurrentDate = new Date();
var GivenDate = new Date(data["PeriodEndDate"]);
if(GivenDate < CurrentDate) {
return '<font color="red"><b>' + data["PeriodEndDate"] + '</b></font>'
} else{
return data["PeriodEndDate"]
}
},
I know that my return value is
<font color="red"><b>2017-08-31T00:00:00</b></font>
My Grid item is
<e-column field="PeriodEndDate" headerText="Period End" width="120" :format='formatOptions' type='date' :valueAccessor="PeriodEndTemplate" :disableHtmlEncode="false"></e-column>
If I remove
:format='formatOptions' type='date' I get a red value like
2017-08-31T00:00:00.
Is there a way to get
2017-08-31 with a red text and still sort like a date in the grid?
I changed my code to :-- It this the best way to do it?
PeriodEndTemplate: function(field, data, column) {
var CurrentDate = new Date();
var GivenDate = new Date(data["PeriodEndDate"]);
if(GivenDate < CurrentDate) {
let myDate = data["PeriodEndDate"].split('T')[0]
let ret = '<font color="red"><b>' + myDate + '</b></font>'
return ret
} else{
let myDate = data["PeriodEndDate"].split('T')[0]
return myDate
}
},
Thanks