Home > SharePoint 2010 > List view web part, show KPI icon images with XSLT

List view web part, show KPI icon images with XSLT

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.

Advertisements
Categories: SharePoint 2010
  1. No comments yet.
  1. May 16, 2011 at 4:00 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: