Search This Blog

Thursday, June 3, 2010

Grouping on People/Group field in SharePNoint XSLT DataView

While grouping SharePoint DataView on People/Group type column(field) , it doesn't produces the expected result. The result comes out as one group for each row in the SharePoint list.
To fix this issue replace following XSL code in dateview:
<xsl:variable name="NewGroup_adhoc">

<xsl:choose>

<xsl:when test="$dvt_groupfield">

<xsl:value-of select="ddwrt:NameChanged(string(*[name()=$dvt_groupfield] | @*[name()=$dvt_groupfield] | current()[name(.) = $dvt_groupfield]), 0)" /></xsl:otherwise>

<xsl:otherwise></xsl:otherwise>

</xsl:choose>

</xsl:variable>


with following

<xsl:variable name="NewGroup_adhoc">

<xsl:choose>

<xsl:when test="$dvt_groupfield">

<xsl:choose>

<xsl:when test="contains($dvt_groupfield, 'Owner')"> <xsl:value-of select="ddwrt:NameChanged(string(substring-before(@Owner,'</A>')), 0)"/></xsl:when>

<xsl:otherwise><xsl:value-of select="ddwrt:NameChanged(string(*[name()=$dvt_groupfield] | @*[name()=$dvt_groupfield] | current()[name(.) = $dvt_groupfield]), 0)" /></xsl:otherwise>

</xsl:choose>

</xsl:when>

<xsl:otherwise></xsl:otherwise>

</xsl:choose>

</xsl:variable>




Note: Owner is the people on which grouping is done

No comments:

Post a Comment