SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function (ctx) {
// get today's date
var today = new Date();
// zero out the time portion so we will only compare days
today.setHours(0, 0, 0, 0);
var tenDaysAgo=newtenDaysAgo = new Date(-864000000);
tenDaysAgo.setHours(0, 0, 0, 0);
var rows = ctx.ListData.Row;
for (var i = 0; i < rows.length; i++) {
// get the date set in your date YourDateField
var itemDate = new Date(rows[i]['Due_x0020_Date']);
// zero out the time portion so we only compare days
itemDate.setHours(0, 0, 0, 0);
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
if (itemDate <= today) {
row.style.backgroundColor = '#ED9898';
}
if (itemDate >= tenDaysAgo && itemDate >today> today) {
row.style.backgroundColor = 'yellow';
}
}
}
});
});
}); });
if (itemDate >= tenDaysAgo && itemDate >today ) {
row.style.backgroundColor = 'yellow';
}