Skip to main content
spell corrections
Source Link
Gaurravs
  • 3.6k
  • 12
  • 23
  • 33

I have a calculated column which returns YES NO. I want to colourcolor code the entire row based on these values. Below is my code using CSR

**(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};
    //OnPostRender call postRenderHandler function.
    overrideCtx.OnPostRender = postRenderHandler;
 
    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function postRenderHandler(ctx) {
    var rows = ctx.ListData.Row;
    for (var i = 0; i < rows.length; i++) {
        var CALOUTPUT = rows[i]["Start of Month"] === "YES";
      //alert(isApproved);
        if (CALOUTPUT) {
            var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
            var tr = document.getElementById(rowElementId);
            tr.style.backgroundColor = "#ada";
        }
    }
}**

CALCULATED Formule

=IF(AND([Due Date]<TODAY(),TODAY()<[0-30days]),"YES","NO")

I have a calculated column which returns YES NO. I want to colour code the entire row based on these values. Below is my code using CSR

**(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};
    //OnPostRender call postRenderHandler function.
    overrideCtx.OnPostRender = postRenderHandler;
 
    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function postRenderHandler(ctx) {
    var rows = ctx.ListData.Row;
    for (var i = 0; i < rows.length; i++) {
        var CALOUTPUT = rows[i]["Start of Month"] === "YES";
      //alert(isApproved);
        if (CALOUTPUT) {
            var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
            var tr = document.getElementById(rowElementId);
            tr.style.backgroundColor = "#ada";
        }
    }
}**

CALCULATED Formule

=IF(AND([Due Date]<TODAY(),TODAY()<[0-30days]),"YES","NO")

I have a calculated column which returns YES NO. I want to color code the entire row based on these values. Below is my code using CSR

**(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};
    //OnPostRender call postRenderHandler function.
    overrideCtx.OnPostRender = postRenderHandler;
 
    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function postRenderHandler(ctx) {
    var rows = ctx.ListData.Row;
    for (var i = 0; i < rows.length; i++) {
        var CALOUTPUT = rows[i]["Start of Month"] === "YES";
      //alert(isApproved);
        if (CALOUTPUT) {
            var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
            var tr = document.getElementById(rowElementId);
            tr.style.backgroundColor = "#ada";
        }
    }
}**

CALCULATED Formule

=IF(AND([Due Date]<TODAY(),TODAY()<[0-30days]),"YES","NO")
Source Link

Calculated column output with CSR

I have a calculated column which returns YES NO. I want to colour code the entire row based on these values. Below is my code using CSR

**(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};
    //OnPostRender call postRenderHandler function.
    overrideCtx.OnPostRender = postRenderHandler;
 
    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function postRenderHandler(ctx) {
    var rows = ctx.ListData.Row;
    for (var i = 0; i < rows.length; i++) {
        var CALOUTPUT = rows[i]["Start of Month"] === "YES";
      //alert(isApproved);
        if (CALOUTPUT) {
            var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
            var tr = document.getElementById(rowElementId);
            tr.style.backgroundColor = "#ada";
        }
    }
}**

CALCULATED Formule

=IF(AND([Due Date]<TODAY(),TODAY()<[0-30days]),"YES","NO")