I've seen a decent amount of info surrounding the conditional formatting but can't seem to get it to work. I want to make the font of the cell red when it's value (which is a date) is in the past.
This is a general idea of what I have now:
{
name: 'IsoDate', index: 'IsoDate', align: 'left', sorttype: 'date', datefmt: "m/d/Y",
formatter: function (cellvalue, options, rowobject) { var now = new Date(); if (cellvalue < now) { return '<span class="error">' + cellvalue + '</span>'; } else { cellvalue; } }
}
I can't seem to get it to work though. I've gotten it to return all red values, or all undefined values. There are some fields with no dates yet.
I'd appreciate any help! Thanks!
UPDATE:
Here is the code I used that ended up working. I actually was referencing another column for the date.
cellattr: function (rowid, val, rawObject, cm, rdata) {
var idate = new Date(rawObject['IsoDate']);
return (idate < new Date()) ? ' class = "ui-state-error-text"' : ' class = "field-validation-green"';
}