本文介绍了Sharepoint 2010 xslt 数据视图:修改表结构以显示列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要显示的图像列表.SharePoint 中的标准模板,每个项目将使用 xsl:for-each 循环并在表格中显示为单行,如下面的示例
I have an image list to be display.Standard template in SharePoint, each item will be looping using xsl:for-each and display in a table as single row like sample below
__________
| |
| image |
|__________|
__________
| |
| image |
|__________|
__________
| |
| image |
|__________|
__________
| |
| image |
|__________|
简单代码:
<xsl:for-each select="$Rows">
<tr>
<td><xsl:value-of ......./> </td>
</tr>
</xsl:for-each>
我需要做的是在每行中显示 3 个项目作为下面的示例
what i need to do is to display 3 item in each row as sample below
__________ __________ __________
| | | | | |
| image | | image | | image |
|__________| |__________| |__________|
__________ __________ __________
| | | | | |
| image | | image | | image |
|__________| |__________| |__________|
如何使用循环在 xslt 中执行此操作.
How can I do this in xslt using looping.
推荐答案
我通常不建议在 XSL 中使用嵌套的 for-each
es,但为了不过度使用 XSLT很多,这个怎么样:
I don't usually recommend using nested for-each
es in XSL, but in the interest of not monkeying with your XSLT too much, how about this:
<xsl:for-each select="$Rows[position() mod 3 = 1]">
<tr>
<!-- Select the (0-based) position within this iteration -->
<xsl:variable name="i" select="position() - 1" />
<xsl:for-each select="$Rows[(position() > ($i * 3)) and
(position() <= (($i + 1) * 3))]">
<td><xsl:value-of ......./> </td>
</xsl:for-each>
</tr>
</xsl:for-each>
这篇关于Sharepoint 2010 xslt 数据视图:修改表结构以显示列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!