Thursday, January 2, 2014

SharePoint 2010: Conditionally Format Fields in a List


This post will be covering how to use a data view web part to apply conditionally formatting to a list.  You might want to use this technique to create simple heat maps for KPIs or as a visual indicator.  An example of when this could be used is to color code expenses which are valued over $1,000.

Materials Needed:
  1. SharePoint Designer 2010
  2. A web page
  3. A List
  4. Dataview web part

In this post I will be assuming that you know how to obtain SharePoint Designer 2010, create a blank wiki or web parts page, and have a list already created that you need to conditionally format.

Now that we have all of that out of the way, let us move onto the How To!

  1. Open SharePoint Designer
  2. Open Your Site
  3.  Enter Your Credentials
  4. Open the library where the page you created is stored, this is most likely in the pages or Site Pages library
  5. Right click the page that you created and select “Edit File In Advanced Mode
After opening the page in advanced mode you should be presented with Design, Split, or Code view.  We will let SharePoint Designer do the heavy lifting for this exercise, so select the Design view.

1.    Click into the web part zone that you would like to have your list displayed
2.    Select the Insert Tab on the Ribbon
3.    Select Data View
4.    Select Your List

You should now have your list on the page as a data view web part.  I have created an example list to show how we can use conditional formatting to better visualize our data.  I will be creating a visual heat map only for my Relationship field for the sake of time, but the same concept could be applied to all of my other list fields.

  1. Select your td
  3. Select List View Tools
  4. Select Options
  5. Select Conditional Formatting
  6. Select Format Selection

  7. You will be prompted with the Condition Criteria Dialog Box
  8. Select the field you would like the condition based upon.  I will be using my Relationship field in order to create my conditions.

  9. Select the comparison and value which makes sense for your situation.  Since this list is only an example I have created extremely basic criteria.
  10. Select Set Style
  11. This dialog will provide you a list of options which could be used to conditionally format your fields.  I will be setting my Background to match the color of the entry.

You will repeat these steps for each condition that you would like to conditionally format for.  Don’t get confused by the term selection, the formation rules will be applied to all of your line items within the column.  I never had to click another td while creating my rules, the conditions will automatically cascade down.

The last step is to save your changes and to do a refresh!  Go check out your conditionally formatted data view web part!

I hope everyone was able to get this to work and fit their needs.  Please feel free to leave a comment or reach out if you have any questions J



No comments:

Post a Comment