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 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.
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: https://sharepointstack.local. Navigate to the Lists and Libraries and click on the Tasks list.
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.
Click inside any field in any list item and choose Format Row under Conditional Formatting on the ribbon.
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.
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.
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
You can modify your existing styles simply by clicking on Modify Style from the style cascading menu.
Save your view and navigate back to your Tasks list. Taraaaaa..! The list is formatted.
Let’s try adding a new Task and set the status to Completed.
As you can see, the new Task was formatted based on our conditional formatting setup.
I hope this was helpful. Enjoy SharePoint-ing