I have the following JS script to color code our custom list items inside out list view, by checking if the item is status does not equal Delivered and its EndDate has been bypassed:-
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
function init() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {},
OnPostRender: function(ctx) {
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++)
{
var currentDate = new Date();
var enddate = rows[i]["EnDDate"];
var status = rows[i]["OrderStatus"];
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
if(row != null) {
if(status != 'Delivered' && enddate && enddate < currentDate
)
{
row.style.backgroundColor = '#FA8072';
row.style.fontWeight = "bold";
}
now the above will not color code anything. the problem i think is that our EndDate
field value will be return as follow 28/09/2018
while the currentDate
will be retruned in the follow format Tue Oct 09 2018 15:09:11 GMT+0100 (GMT Daylight Time)
.. so i think this will make my comparison enddate < currentDate
return unexpected results! so can anyone advice on this please?