0

Example of Table columns to colour code

I have a table where by I want to colour code column names "WIS Completed" depending on whether status of facilities (Data Modelling, Data Logistics, RPT, NC, Paint, Trim, Composites and Model Shop( is "Pending" "Problem" "WIP" "Accepted" "Completed" etc.

Ultimately If 1 status is “Stopped”, “Problem” or “Rejected” Cell “WIS Completed” is to be RED

If no status' are “Stopped”, “Problem” or “Rejected” but 1 status is “Accepted”, “Pending” or “WIP” Cell “WIS Completed” is to be YELLOW

If no status “Stopped”, “Problem”, “Rejected”, Accepted”, “Pending” or “WIP” and 1 status is “Completed” Cell “WIS Completed” to be GREEN

1 Answer 1

1

Use a Calculated Column StatusColor to built your logic and determine a Color

Then either

  • use some 25 lines of SP2013 Client Side Rendering JavaScript code
    to color the rows based on the calculation

    Examples: https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

    You can determine the color within the script file; but that requires (more) editting for any future changes.

  • or stuff the HTML/JavaScript in a second Calculated column (set to datatype=Number)
    to Color the row with 2 lines of JavaScript

    ="<img src=""/_layouts/images/blank.gif"" onload=""{"
        &"var TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"                
        &"TR.style.backgroundColor='" 
     &[StatusColor]
        &"';"
     &"}"">"
    

More Pros & Cons of this at: http://www.viewmaster365.com/#/How

2
  • Javascript link: learningsharepoint.com/2013/04/04/…
    – Patrick
    Oct 6, 2015 at 10:11
  • @Patrick, that CSR example creates a whole new HTML structure instead of using the existing Table. So you loose .. I better say destroy.. all the sorting, selecting, every SharePoint does for you. Oct 6, 2015 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.