Humans are visual by nature so creating a graphic icon for a list of items or tasks can be extremely beneficial when trying to sort through data. Without having to configure SharePoint Designer or writing custom code, you can create a simple color coded icon that will enhance your list tremendously in just a few minutes.

 

Step 1- Create a “Color” column in your list. This column can either be calculated using other data with in the list or selected manually on creation.
Example: 
=IF(OR(Status="Not Started",Status="Deferred"),"Yellow",IF(OR(Status="In Progress",Status="Complete"),"Green",IF(Status="Waiting on Someone Else","Red")))
 
·        Tip - For a list of available colors, click here.
Step 2- Create a “Status” column that is a calculated value. The output is a single line of text. Copy and paste this into the calculated field:
="<DIV style='font-weight:bold; font-size:24px; color:"&Color&";'>•</DIV>"
Step 3- Add the list to your web part or wiki page
Step 4-   Edit the web part to show the Status column
Step 5 – Add a Content Editor Web Part directly underneath the List/Task Web Part
Step 6- In 2010, you will need to load the below code to a location on your site in a text file and point the content editor to the location. In 2007, you can copy and paste the below code into the content editor settings box itself.
You have now completed you color coded list! If you want to learn more about color coding lists and other ways SharePoint can benefit your business, please contact me at Anjali.Bharadwa@dmcinfo.com
<script type="text/javascript">
//
// Text to HTML
//
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length) {
try {
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
//
// ExpGroupRenderData overwrites the default SharePoint function
// This part is needed for collapsed groupings
//
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("DIV");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";
var theTBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var TDContent = " ";
while (j < theTBODYTDs.length) {
try {
TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTBODYTDs[j].innerHTML = TDContent;
}
}
catch(err){}
j=j+1;
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>
Share this page:

Comments

-->
# Ollivier
Thursday, July 21, 2011 9:00 AM
Hi.
It's exactly what I was looking for ! But (always a but), I still have the formula in the Status column (with the right color written) and not the point after loading the txt.
problem of language (system in french) ? One strange thing, when I open my txt file in IE, ... empty and when I edit it from the file explorer, the text is here. May be because of the security on the server (does'nt accep txt file ...) Thx a lot.
-->
# Anjali
Thursday, July 21, 2011 9:24 AM
Don't worry too much about the blank IE box as the same thing happens to me. One thing you really have to be sure of is that the Content Editor box is directly under your list actually in the same web part layout box or it will not work.
-->
# Ollivier
Friday, July 22, 2011 6:05 AM
It works but only with the list default display, with the others styles ... Thx
-->
# 0000
Friday, September 23, 2011 5:53 AM
dhththt
-->
# Francisco
Wednesday, November 23, 2011 6:48 PM
Works great but when I set the view in the following way I only see the html output not the color.

Group by Category Field and make the list expanded.
-->
# JP
Friday, December 30, 2011 5:25 AM
Hi Anjali
Thank you for your great post.
I had similar work done with images displayed please refer URL http://www.sharepointcommunity.com/spcblog/Lists/Posts/Post.aspx?ID=77

after migrating to 2010 it is displaying as html code. I did change the content editor script from sharepoint location as described in step 6 it still not showing up the image. Any help would be appreciated
thanks
-->
# Douglas
Thursday, January 12, 2012 4:56 PM
Hi Anjali
Thank you for your great post.
It has been very helpful.Anything on Shading a field?
-->
# Riteja
Friday, February 24, 2012 7:43 AM
It worked for me! Fantastic Post... thanks!
-->
# Sugandh
Sunday, February 26, 2012 10:45 PM
Thanks Anjali,
Thanks a ton!
I tried out the same and it worked
Please make sure that you drag the content editor webpart under the list for this to work. It wasn't working for me untill I brought the content editor webpart to the bottom.
-->
# Rosendo N.
Tuesday, March 27, 2012 7:24 PM
Anjali,

This is great thank you. I have grouped the tasks so they can be collapsed or expanded in the web part. Once I did so color status has reverted back to code. Any idea how to get it to work if the task is grouped?

Much appreciated.

RN
-->
# Shiral F
Wednesday, April 11, 2012 12:04 AM
Hi Anjali,

Thanks for this.. I was able to tweek this to create a rolling health monitor for 320 store that looks awesome..

Thanks Again..
Shiral.
-->
# LH
Tuesday, April 24, 2012 2:15 PM
What is wrong with this logic?

=“Green”,IF(OR(Status=”On Schedule”,”On Budget”),”Yellow”,IF(OR(Status=”Schedule Concerns”,”Budget Concerns”,”Red”,IF(OR(Status=”Serious Schedule Concerns”,”Serious Budget Concerns”)))

I am attempting to install a three button option and have never done this before. I am more of a user, not developer. Also, What is the follow up logic for the status column? Thank you
-->
# Anjali
Tuesday, April 24, 2012 2:33 PM
Thanks for reading my blog. Unfortunately it looks like your syntax for the logic is off. An IF statement works like this: IF(condition, then, else). It may help to review these available calculations http://msdn.microsoft.com/en-us/library/bb862071.aspx. Hope that helps.
-->
# Joel
Tuesday, May 01, 2012 10:01 AM
Thanks for the excellent tip! One problem I am having though....... when I sort one of the fields, the color coding dissapears. Refreshing the page returns the list to it's previously sorted state. Is there a way to get this to work?
-->
# Timmah!
Wednesday, May 02, 2012 2:20 PM
AMAZING...my co-workers are going to think I'm super intelligent!

Thanks for the awesome tip!
-->
# Chris
Friday, May 11, 2012 11:38 AM
This is exaxctly what I am looking for, but I am recieving an error "circular reference (the calculated column refers to itself)" when using your example for status. I tried making the Color logic refer to a choice column called mychoice, so the user makes the choice, the color column assigns a color based on that choice, etc... Am I misunderstanding the logic here? In your example above, it seems like the color column refers to a "choice" field called status yet the status itself is a calculated field? I am on Sharepoint 2007, thank you!
-->
# Michelle
Tuesday, May 15, 2012 10:44 AM
I am in Foundation SharePoint 2010 and when I create a column with the calculated field I get an error

"The formula refers to a column that does not exist. Check the formula for spelling mistakes or change the non-existing column to an existing column.
-->
# Douglas
Tuesday, May 15, 2012 6:57 PM
Anything on Shading a column or a cell/field?
-->
# Pete
Monday, May 21, 2012 7:58 AM
Nothing is working for me. Won't even let me create a Status column with that line of code in the formula.

Post Comment

Name (required)

Email (required)

Website

Enter the code shown above in the box below