Friday, October 26, 2012

Apply colour coding to your SharePoint lists

Color coding is very useful to highlight key items in a list. For example in an issues list, you may want to draw the users’ attention on items with high priority.
In the picture below, I have aggregated 4 different ways to do it:


This customization was entirely done through the SharePoint UI. Let’s see how.


The method
I am simply going to apply my post about using calculated columns to write HTML. For each example, we need to figure out the formula that will create the HTML string. Then the script, included in a CEWP, will make it behave as real HTML.

The formulas
In my example, I am applying color coding based on the priority of each issue: red for high, yellow for normal and green for low. Note that the formulas below were built for an issues list, formulas for other lists or libraries may be slightly different.
So here we go, please refer to the above picture to see the result:
- Traffic light (actually a big bullet!):
=”<DIV style=’font-weight:bold; font-size:24px; color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>•</DIV>”
ALSO, instead of CHOOSE you can use IF statements. For example:
IF( [status]=”open”, “red”, IF([status]=”in progress”, “orange”, “green”))
- Indicator (reusing the default SharePoint KPI images):
=”<DIV><IMG src=’/_layouts/images/KPIDefault-”&(3-RIGHT(LEFT(Priority,2),1))&”.gif’ /></DIV>”
- Font color:
=”<DIV style=’font-weight:bold; font-size:12px; color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”
- Background color:
=”<DIV style=’font-size:12px; background-color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”
Simply paste your preferred formula in a calculated column, add the script on the Web page as explained here, and voila!

No comments:

Post a Comment