Archive

Archive for May, 2011

List view web part, show KPI icon images with XSLT

May 11, 2011 1 comment

I ran into a requirement where customer was using SharePoint standard version only and did not have KPI web part available. Requirement was simple to display red, green, yellow icon in list view web part. You can write a little XSLT to acheive such things like display image based on status or change colors. You can open you page in designer and choose edit file. Your page will load in designer. I always keep display mode as split mode so i can see code and design both at a time. You need to select the web part, you will see Conditional formatting big icon on the ribbon if you just want to change the colors based on conditions. It does not need XSLT manual update by you. But if you need to show image, you can select your column and in the code selection, paste this XSLT to show the image 

 <img alt=”Project Status”>
  <xsl:attribute name=”src”>
   <xsl:choose>
    <xsl:when test=”normalize-space($thisNode/@Project_x0020_Saate) = ‘Green'” ddwrt:cf_explicit=”1″ xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime”>/_layouts/images/KPIDefault-0.GIF</xsl:when>
    <xsl:when test=”normalize-space($thisNode/@Project_x0020_Saate) = ‘Yellow'” ddwrt:cf_explicit=”1″ xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime”>/_layouts/images/KPIDefault-1.GIF</xsl:when>
    <xsl:when test=”normalize-space($thisNode/@Project_x0020_Saate) = ‘Red'” ddwrt:cf_explicit=”1″ xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime”>/_layouts/images/KPIDefault-2.GIF</xsl:when>
    <xsl:otherwise>/_layouts/images/KPIDefault-2.GIF</xsl:otherwise>
   </xsl:choose>
  </xsl:attribute>
  </img>

you will see out put like following , Please note that i am using column values just for demostration purpose, You can do it for any status column and change above values in XSLT.

Categories: SharePoint 2010