3

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!

2

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.

  • Looking back at this, I would say this is the best solution. Easy implementation with no undesired effects. – tehman Mar 26 '15 at 15:15
7

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! :)

  • 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
  • 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
  • Sorry, I'm working only with SharePoint Foundation, and I definitely can't reproduce your issue and provide any solution, bcz InfoPath forms are only avaliable in SharePoint Server. So probably the best decision for further investigation for you will be to post a new question. – Andrey Markeev Sep 26 '11 at 11:52
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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