, , ,

When you read the title you probably think I will discuss about client side rendering, but I am not. This example is based on SharePoint 2010 an no client side rendering is available for this web part. But you still can do this using classic XSLT and customize only specific items from the view.

I had a list containing time off requests with a lookup column called “Activity” (internal name is the same). By default, this kind of field is render like a hyperlink to the item from lookup list and, by mistake, some users clicked on this link instead of clicking on edit icon.

Timesheet - 0_Start view - Internet Explorer

If you want to remove the hyperlink, open the page with SharePoint Designer and add this code below “XmlDefinition” node.

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
<xsl:include href="/_layouts/xsl/main.xsl"/> 
<xsl:include href="/_layouts/xsl/internal.xsl"/>


And now we are ready to add customization code for “Activity” field, which contains only a few lines of code, inside “xsl:stylesheet” declaration.

<xsl:template match ="FieldRef[@Name='Activity']"  mode="Lookup_body">
<xsl:param name="thisNode" select="." />
<xsl:param name="activity" select="substring-after($thisNode/@Activity.,'#')" />
<xsl:value-of select="$activity" disable-output-escaping="yes" />

Please note that activity parameter doesn’t take the value from “@Activity” attribute of current node. Instead “@Activity.” is used (a dot is added to attribute name). Also, we need to make a “substring-after” operation because the data obtained from the server has this format: “2;#Holiday”.
Timesheet - 1_My time - Internet Explorer