Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

So I have a document library where I have a column with numerical values. Is it possible for example to color code/Highlight items in the column to green if they are less than 10, yellow if less than 20, and red if less than 50?

I'd prefer a way with least use of written code.

Thanks!

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You can easily achieve this, using SharePoint Designer and conditional formatting feature.

Just open your SharePoint designer, navigate to the document library, and under Views section, click on "AllItems.aspx".

Then, you will see the designer for view.

enter image description here

Select the particular item you want to colorize (make sure td element is selected, as it shown on the screenshot above), right-click on it and select "Conditional formatting":

enter image description here

The conditional formatting panel will appear on the left. Select "Create" => "Apply formatting...".

enter image description here

You will see now the condition criteria form.

enter image description here

Apply needed filters (you can select field name, comparison operation, and the value to compare), and then click "Set Style", and select background color.

No code at all! :)

share|improve this answer
    
this seems like it should work, but I can only get one condition to work at a time. is there a work around for this? –  tehman Sep 23 '11 at 17:39
    
never mind, got it. Thank you :) –  tehman Sep 23 '11 at 17:48
    
What do you mean one condition? In the Condition Criteria form you can specify more than one condition, and connect them with "Or"s or "And"s. Don't you see the link Click here to add a new clause, and the And/Or column on the screenshot? :) –  Andrey Markeev Sep 23 '11 at 17:48
    
ok, very well :) –  Andrey Markeev Sep 23 '11 at 17:49
    
when I do this formatting, It changes my form from being opened in a browser to being opened as an XML/infopath form. Is there a way to revert back to using a browser enabled form? –  tehman Sep 26 '11 at 11:48

There is the HTML calculated column method discussed here: http://blog.pathtosharepoint.com/2008/09/01/apply-color-coding-to-your-sharepoint-lists/

And you could use JQUERY by itself, with small bits of JS.

<script src=".../jquery.js" type="text/javascript"></script>

<script> 

    $(document).ready(function(){

        $Text = $("td .ms-vb2:lt(50)").css("background-color", "#FF0000");

    }); 

</script>

The above is pretty simple, and would color any item in the list that has a number in it less than 50, but the concept is there.

share|improve this answer

I've written an article on the various ways of achieving this. These are (in summary):

Client based

  • JavaScript: Put some JavaScript code into a Content Editor Web Part (as linked by @Jesus Shelby)
  • Designer: Use SharePoint Designer to set up Conditional Formatting (as explained by @Omlin)

Custom Field Type

  • Code it yourself: Make your own custom field type from scratch
  • Buy: Purchase a pre-made solution (naturally, I recommend our own product 'SharePoint Highlighter')

More information, links, and persuasive sales talk can be found in the article: How to do list highlighting in SharePoint

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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