Tuesday, April 29, 2008

Showing icons in a list view

My customer threw me a challenge: instead of your typical Red/Amber/Green SLA indicator, they also want to show Blue if they've exceeded the SLA target. And no yellow - either you're red, missed; green, on; or blue, exceeded. So much for using the KPI interface!

I started looking in to the KPI Dashboard sample to see if I could somehow customize this, but after an hour and a cup of Starbuck's it was still none too clear. Then the coffee cleared away the neurons & I recalled seeing discussion on using the spankin' new XSLT Data Viewer. I had done used this with SPS 2003 and it was pretty good then...and it's better now with MOSS.

The XSLT Data Viewer is a MOSS goodie, sorry WSS'ers. To use it, I fired up SharePoint Designer, opened up my list, changed to the 'Split' view, then with a right click I chose the Convert to XSLT Data View option.

In my list I have a SLA column, a Target column, and a Status column. I wanted the indicator in the Status column.

After a few seconds (slow on the VPC for some reason) I was able to view the list. Looking at the XSLT, for the Status column, I changed what was there to:

<!--Status-->
<TD Class="{$IDAVVHVE}"><xsl:choose>
<xsl:when test="@SLA amp-gt; @Target">
<img src="/_layouts/images/KPIDefault-Blue.gif" alt="Exceeded SLA Target"/>
</xsl:when>
<xsl:when test="@SLA= @Target">
<img src="/_layouts/images/KPIDefault-2.gif" alt="Met SLA"/>
</xsl:when>
<xsl:when test="@SLA amp-lt; @Target">
<img src="/_layouts/images/KPIDefault-0.gif" alt="Missed SLA"/>
</xsl:when>
</xsl:choose>
</TD>

Change the 'amp-gt;' to an ampersandgt; (I should find a better blog page) and 'amp-lt;' to the ampersandlt; and you're good to go!

Now I need to come up with a nice shape for the Blue icon. Blue Moon? mmmm, tasty, good idea!

No comments: