我有一个带有“proposalID”列的sharepoint 2010列表。该列中的值为 5555-01,5555-02,5555-03,6666-01,6666-02等。
我想按短划线左侧的4个字符进行分组。因此,分组将显示5555下的3个项目和6666组下的2个项目
使用Sharepoint Designer 2010,我添加了一个空白的dataview webpart,连接到我的列表,并从功能区中选择按Proposal ID列排序。它呈现了以下xsl ddwrt代码:
我一直在尝试各种语法来改变字符串函数,但还没有成功。我试图从这篇帖子中收集一些知识,http://jamestsai.net/Blog/post/SharePoint-Data-View-Data-Form-Web-Part-Group-items-by-month-on-DateTime-field.aspx - 但是无法将字符串语法应用到我的案例中。
有人可以建议我如何完成这个分组吗?提前谢谢。
<xsl:choose>
<xsl:when test="not ($dvt_groupfield)">
<xsl:value-of select="ddwrt:NameChanged(string(@ProposalID), 0)" />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
答案 0 :(得分:2)
根据该博客文章,我认为以下内容适用于这种情况:
<xsl:choose>
<xsl:when test="not ($dvt_groupfield)">
<xsl:value-of select="ddwrt:NameChanged(string(substring(@ProposalID, 1, 4)), 0)" />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
使用1和4作为子串的边界。
同样对于标题,也如博客文章中所示:
<xsl:when test="not (@ProposalID) and (@ProposalID) != false()">
<xsl:value-of select="' '" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(@ProposalID,1,4)" />
你可以尝试一下吗?