Introduction

This blog is mainly focused on SharePoint
I will use this to store and share all the tips and tricks about SharePoint and the related products
List of all posts

xsl template : Adding calculation in a group header


Topic xsl template : Adding calculation in a group header
Output Groupe Name + Result of formula

Step Description
1 Create the template
<xsl:template name="FieldRef_Text_body.Display_x0020_Name" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Display_x0020_Name']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:choose>
     <xsl:when test="@AutoHyperLink='TRUE'">
   <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
  </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/></xsl:otherwise>
    </xsl:choose>
 </xsl:template>
this is the default template create by sharepoint 2010
2 Add the calculation part (after param and before choose) 1° we will store in a variable the selection criterium for the calculation
<xsl:variable name="cname" select="$thisNode/@Display_x0020_Name" />
2° we will select only the rows that match our criterium in the calculation
<xsl:variable name="WD select="sum($Rows/Row[@Display_x0020_Name = $cname]/@Work_x0020_Days)"/>
3Add the calculation result (after the xsl:choose closing tag
<xsl:value-of select="$WD"/>
4If you want to add space between info, just add the following
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">&nbsp;</xsl:text>

No comments:

Post a Comment

by Category