SharePoint Lists Conditional Formatting using SharePoint Designer 2010


I was asked on different occasions if SharePoint supports conditional formatting on Lists. The answer was yes Smile It can be done using SharePoint Designer. Back in SharePoint 2007 (MOSS) we had to convert the List View Web Part to a XSL Data View to be able to set up conditional formatting. Gladly in SharePoint 2010 this is not required anymore. Conditional formatting evolved pretty much since 2007. Nevertheless, today we will go through creating conditional formatting on a SharePoint Tasks list. We will try to format the list item background color based on the task status field value.

image

Let’s start by launching SharePoint Designer 2010 and open our target site. I created the list on this blog so the address will be: http://sharepointstack.local. Navigate to the Lists and Libraries and click on the Tasks list.

image

Right click the All Tasks view and select Edit File in Advanced Mode. Bear in mind that we are editing only the All Tasks view, formatting set here will not be reflected on the other views.

image

Click inside any field in any list item and choose Format Row under Conditional Formatting on the ribbon.

image 
Inside the Condition Criteria dialog, set the Field Name to Status; Comparison to Equals, and Value to Not Started. The cool thing about Choice fields is you don’t have to write the value, the dropdown will contain all the field values. So our criteria will apply only to tasks where the Status field value equals Not Started. Click on Set Style.

image

In the Modify Style dialog, click on Background and modify the background-color value. Remember, this is CSS we are setting on XSLT, so we can add and format background images as well.

image

You will need to repeat this for the rest Task statuses: In Progress, Completed, Deferred, and Waiting on someone else. While you are setting up conditional formatting you will notice the Conditional Formatting pane on the right with all created styles. I know what is going in your mind, No you can’t copy the styles from the pane and paste them in another view Winking smile

image

You can modify your existing styles simply by clicking on Modify Style from the style cascading menu.

image

Save your view and navigate back to your Tasks list. Taraaaaa..! Open-mouthed smile The list is formatted.

image

Let’s try adding a new Task and set the status to Completed.

image

As you can see, the new Task was formatted based on our conditional formatting setup.

image

I hope this was helpful. Enjoy SharePoint-ing Smile

Comments (27)

  1. Anonymous says:

    +1

  2. Thanks for the +1 🙂

  3. Anonymous says:

    If i have to work on Assign To coloumn how should i procced

  4. Anonymous says:

    Now try to add this view(All Tasks) of the list in a webpart and see if you conditional format is still there….

  5. Anonymous says:

    I am working on a project and in a collumn I am trying to get any numbers greater than 7 to be green, any numbers greater than 0 but equal to 7 yellow and any numbers less than or equal to zero red. How do I do this?

    Thanks for your help!

    1. Beto says:

      @ Balsharfi

      I have the same situation as Elijah. I have a custom list where I created three columns (Date1, Date2, Date3). I have Date3 column populate with the number of days difference between Date1 and Date2. Now, I want the Date3 color code like Red as =32 and 60. For some reason, when I apply this conditional formatting styles to the entire Date3 column, it does not show. Any guidance is greatly appreciated.

      Thank you.

      1. Beto says:

        Sorry but what I typed didn’t show as it should be. Red should be for numbers less than 31; Yellow for 32 through 59; and greater or equal than 60.

  6. @Jitendra Ingale

    Such columns use different construct like custom and lookup, it uses this format for example ;#id;#login;#, check the XML sent back to you and then filter with a string that matches the returned format.

  7. @Floris

    I did and it did not work, I got the default XSLT instead. It would not make sense as well to customize every webpart you would place on the pages! I guess by now you found a solution for it. Sharing is caring =)

  8. @Elijah

    1- Is this a custom list or an OOTB list?

    2- Is it a single line of text or a number feild?

  9. Anonymous says:

    colour coded OK but when I add the list to a page as a webpart (the list has only one view) colour coding is lost, any suggestions?

  10. Anonymous says:

    Did not work.  List view in SP remains the same even though it works in same view in edit window of SP Designer.

  11. Anonymous says:

    How to convert the List View Web Part to a XSL Data View in sharepoint designer 20073

  12. Anonymous says:

    But it did not displayed on customized page through sharepoint designer… I have called a view on designer wiki page for that list.. it is working fine on Foundation but did not worked on while navigating the page. Please help

  13. Anonymous says:

    Hello

    I am having the same problem as listed above. The colors from formatting are showing up in SharePoint designer but not on the actual SharePoint site when opened through a browser. Is there a fix for this?

  14. Anonymous says:

    I take it this feature is on the enterprise version only?  When I right click all I get is Rename.  

  15. Anonymous says:

    Jitendra Ingale @ To Assign , you haveto create a task list and add the members to the SharePoint site. And Enable the Option "Send Email to the Assign Group or Partner" ..

    Thanks,

    Sai.N

  16. Anonymous says:

    Jeff & Setu Bhardwaj

    Open the SharePoint > Edit in the SharePoint Designer > Lists > Select All Items > Click on the Coloumn which you want to use that as Condition > Go to Conditional Formating Option > Format Row > Now add your conditions in that. This should work fine…

    Thanks,

    Sai.N

  17. Thanks for the clear instructions and the snapshots.

    I have acknowledged it in my own blog:

    afsawaf.blogspot.com/…/sharepoint-2010-conditional-formatting.html

  18. Anonymous says:

    what if i want to hide status colum?? formatting dosen't work in that case as referencing column is not present in the list. how do i resolve this. any solution for that? plz help

  19. Anonymous says:

    Rani…Could you please provide few more details about the same ???

  20. Anonymous says:

    Good. This article helped me.

  21. BALSHARFI says:

    Thanks Asad. Glad to hear that 🙂

  22. ARCHANA GOVINDASWAMY says:

    Thanks its helpful post.

  23. Anonymous says:

    I tried to do this in SharePoint Designer 2010 and when I go to edit file in advance mode it opens in HTML Why is it not opening correctly?

  24. Anonymous says:

    This is great and easy to do. How about for rolled-up lists. We have tasks under initiatives under goals. I want the top goal background color to change if everything is not completed. So far, if everything is not completed it is set to yellow. However, I want it to change to red if a task is past due or if status is 'work stoppage'. I can't seem to make that happen.

  25. Kelly says:

    Thank you for this!