Using CSR to change row color - how do I keep the view style shaded view ?
It seems the CSR in a CEWP only works if I keep the view style on default.
How do I keep the code working but have the view style remain in shaded view?
My code is below:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var CategoryColors = { 'Training': '#6699ff', };
var rows = ctx.ListData.Row;
for (var i = 0; i < rows.length; i++) {
var Category = rows[i]["Category"];
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
row.style.backgroundColor = CategoryColors[Category];
}
}
});
});