我有一个 sharepoint 2010 列表,其中包含“proposalID”列。该列中的值为 5555-01、5555-02、5555-03、6666-01、6666-02等
我想按破折号左侧的 4 个字符进行分组。因此,分组将在 5555 下显示 3 个项目,在组 6666 下显示 2 个项目,依此类推。
使用 Sharepoint Designer 2010,我添加了一个空白数据 View Web 部件,连接到我的列表,并从功能区中选择按“提案 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>
最佳答案
根据该博客文章,我认为以下内容适用于这种情况:
<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)" />
你能尝试一下吗?
关于xslt - sharepoint dataview webpart xslt 按列的左侧字符分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14365437/