Friday 8 June 2007

SharePoint 2007 - Tweaking the Data View with XSL

Following the Data View Basic Printing Page a small tip to show the use XSL in a Data View. What we will di is change status items e.g. High / Medium / Low into images in a Data View. These is nice to beautify your DataViews

Find the xsl:value for the column containing your status field.

<td class="ms-vb" style="width: 50px">
< xsl:value-of select="@Status"/>
</td >

and change it to an xsl:choose

<xsl:choose>
<xsl:when test="@Status = 'Low'"><img src="/PublishingImages/Green.png"/></xsl:when>
<xsl:when test="@Status = 'Medium'"><img src="/PublishingImages/Blue.png"/></xsl:when>
<xsl:when test="@Status = 'High'"><img src="/PublishingImages/Red.png"/></xsl:when>
</xsl:choose>

This checks the Status and displays an small icon according to the choosen status item.