How to implement rule on SharePoint list and design color SharePoint list

November 2nd, 2009 | Categories: Customization, SharePoint | Tags: ,

SharePoint designer has many features and one of the features is to design the SharePoint list and implement rule over there. You can implement bi-color on any SharePoint list by using SharePoint designer.

This article is to help you to understand how to design a list in a SharePoint page, implement rule on the list and accordingly change the layout and color of the different rows of the list based on the associated rule.

Let’s start with a example list having fields First Name, Last Name, Due Date, Pay Date and Pay Status. This list contains the information of the policy holders; who paid their policy amount and within the due date or after the due date or not paid etc. The objective is to quickly distinguish the list of users who are the Defaulters i.e. who pay after the Due Date. Similarly we need to classify who are in the list didn’t pay.

The basic and simple approach is to create different view for Defaulter and non-paid one. Using this view, we can easily find out the list of people, who are in the Defaulter category. However we can follow alternate approach as well. Instead We need every data will be in same list and we can distinguish those defaulter and non-paid people easily. Having said that, it clarifies, we can easily found the name of the person who didn’t pay their policy amount. So we need to tag those rows by using some color, let’s say background color, and display the entire list in the page.

Let’s see how to achieve the goal. Create the list in SharePoint and open the site in SharePoint Designer. Open the default.aspx page (or any page you have created) and drag the list into the page.


In the designer, you can find the he following XSLT after dragging the list. Check the filed name in XSLT i.e. First_x0020_Name. SharePoint replace the space in the filed name with _x0020_ in internal field name.


<tr><td class=”ms-vb”>
<xsl:value-of select=”@First_x0020_Name” /></td><td class=”ms-vb”>
<xsl:value-of select=”@Last_x0020_Name” /></td><td class=”ms-vb”>
<xsl:value-of select=”ddwrt:FormatDate(string(@Pay_x0020_Date), 1033, 5)” /></td><td class=”ms-vb”>
<xsl:value-of select=”ddwrt:FormatDate(string(@Due_x0020_Date), 1033, 5)” /></td><td class=”ms-vb”>
<xsl:value-of select=”@Pay_x0020_Status” /></td>

To implement rule on the SharePoint list, select one entire row and then go to the Condional Formating in the SharePoint Designer (left right corner). Click on Create >> Apply formatting

Condition Criteria Popup window appear. In this GUI you can define your rule. Select the field name ‘Pay Status‘ and Comparison as Equals. Go to the Value field, and select the value ‘Defaulter‘ from the drop down list and click on OK.

Next, you need to apply the STYLE for those rows where the specified rule will satisfy. In the Modified Style window, select the background under Category and select a background color. In this example background color is RED.

Click on OK. It’s done. In the designer the rule has been implemented.

Have a look on the XSLT, it has been modified and the new rule is reflected there:



<tr>
<xsl:attribute name=”style”>
<xsl:if test=”normalize-space(@Pay_x0020_Status) = ‘Defaulter’”>background-color: #FF0000; color: #00FF00;</xsl:if>
</xsl:attribute>
<td class=”ms-vb”>
<xsl:value-of select=”@First_x0020_Name” /></td>
<td class=”ms-vb”>
<xsl:value-of select=”@Last_x0020_Name” /></td>
<td class=”ms-vb”>
<xsl:value-of select=”ddwrt:FormatDate(string(@Pay_x0020_Date), 1033, 5)” /></td>
<td class=”ms-vb”>
<xsl:value-of select=”ddwrt:FormatDate(string(@Due_x0020_Date), 1033, 5)” /></td>
<td class=”ms-vb”>
<xsl:value-of select=”@Pay_x0020_Status” /></td>
<xsl:if test=”$dvt_1_automode = ’1′” ddwrt:cf_ignore=”1″>
<td class=”ms-vb” width=”1%” nowrap=”nowrap”>
<span ddwrt:amkeyfield=”ID” ddwrt:amkeyvalue=”ddwrt:EscapeDelims(string(@ID))” ddwrt:ammode=”view”></span>
</td>
</xsl:if>

Now, refresh the SharePoint page and you may face the following error:

This Page has been modified since you opened it. You must open the page again.

Refresh page.
Troubleshoot issues with Windows SharePoint Services.

This might be because you are in shared view mode. Close your browser and open a new browser and check your site and here it goes.

Next step is to implement another rule on top of this rule. Need to use other color for those users who didn’t pay at all. Also need to implement paging on this SharePoint List.

How to implement paging in the SharePoint List

Select the list and there is one arrow in the top right corner of the list (fig: SharePointPaging.JPG). Click on this, ‘Data View Properties’ window let you to implement pagination in SharePoint. Click on the Paging tab and select the middle one i.e. Display items in sets of the size: and put the number you want to display  the records per page. In this example it is 7.

Click ok. Paging nation is done. Next do some interior decoration. Allow user to sort data through Date column i.e. by filed name. Click on Conditional Formatting in the Common Data View Task window. Select General tab and enable sorting and filtering option.

Finally, we need to implement another rule i.e. point out those user who didn’t pay. Need to follow the same process i.e. create a rule process. In Condition Criteria Popup window, we need to implement the new rule. Select filed name Pay Date and select the IsNull as comparison operator and click on OK.

In the Modified Style window, select the background as pink and click on OK. In the designer, it is reflected and the XSLT has been changed.

Modified XSLT:

<xsl:if test=”normalize-space(@Pay_x0020_Status) = ‘Defaulter’”>background-color: #FF0000; color: #00FF00;</xsl:if>
<xsl:if test=”normalize-space(@Pay_x0020_Date) = ””>background-color: #FF00FF;</xsl:if>

Finally save the file in SharePoint designer and refresh the SharePoint site and it looks like as below:

Hope this will help you.

  1. June 26th, 2010 at 10:16

    Good brief and this fill someone in on helped me alot in my college assignement. Thank you on your information.

  2. September 15th, 2010 at 15:37

    great blog thank you

  3. December 2nd, 2010 at 21:20

    Hello you I absolutely dig your blog, I wuold feel very special if you would want me to publish a honest review about your awesome webblog on my own Dining Site http://www.fette-fotzen-chat.de/ would you grant me permission? Yours

  4. December 3rd, 2010 at 23:34

    Hey 6a827t8vxziyyyo64tob, very interesting post, it really got me thinking. 4knymddhdl gr3nwz4nzv Thank you. isbasbrt2q
    vwy92sugd6

  5. December 6th, 2010 at 10:27

    Coole Site. Nice!

  6. December 7th, 2010 at 02:52

    scooby dooby doo!

  7. Himadrish
    December 25th, 2010 at 06:07

    Thanks, I will check and try to fix the same soon :)

  8. January 21st, 2011 at 13:06

    I had enjoyable reading this article. I wish to read a lot more on this topic.. Thank you for sharing this remarkable post.. Anyway I am going to subscribe to your feed and I hope you write wonderful articles again soon.

  9. March 17th, 2011 at 02:49

    know i’m a little off topic, however i just wanted to say i like the particular layout of the website. I’m new to the blogegine platform, so any suggestions on getting my blog looking nice would be appreciated.

2 trackbacks

  1. IFRS Website Trackback | 2011/12/09
  2. Underwater Video Camera Trackback | 2012/01/05
You must be logged in to post a comment.