2013-02-05 60 views
0

我有一個圖像列表顯示。在表中作爲單列樣以下Sharepoint 2010 xslt dataview:修改表結構來顯示列表項

__________ 
|   | 
| image | 
|__________| 
__________ 
|   | 
| image | 
|__________| 
__________ 
|   | 
| image | 
|__________| 
__________ 
|   | 
| image | 
|__________| 

簡單的代碼,每個和顯示此:在SharePoint 標準模板,每個項目將使用XSL循環

<xsl:for-each select="$Rows"> 
    <tr> 
     <td><xsl:value-of ......./> </td> 
    </tr> 
</xsl:for-each> 

我需要什麼做的是每一行作爲樣本下面

__________  __________  __________ 
|   | |   | |   | 
| image | | image | | image | 
|__________| |__________| |__________| 
__________  __________  __________ 
|   | |   | |   | 
| image | | image | | image | 
|__________| |__________| |__________| 

顯示3項我如何使用循環爲此在XSLT。

回答

0

我通常不建議使用XSL嵌套for-each上課,但不是與你的XSLT胡鬧了太多的利益,這個怎麼樣:

<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() &gt; ($i * 3)) and 
            (position() &lt;= (($i + 1) * 3))]"> 
     <td><xsl:value-of ......./> </td> 
     </xsl:for-each> 
    </tr> 
</xsl:for-each> 
+0

非常感謝。這是我需要的 – user1126128

0

另一種方式來做到這一點是使用<li>代替的表格單元格。這從底層數據正確設置了演示文稿。使用適當的CSS,您可以根據Web部件(?)的可用寬度來包裝列表項。

<style> 
.imagelist li { float: left; } 
</style> 

然後...

<ul class="imagelist"> 
<xsl:for-each select="$Rows"> 
     <li><xsl:value-of ......./> </li> 
</xsl:for-each> 
</ul> 
當然

,你可能需要一個「寬度」樣式規則添加到列表中的web部件/容器 - 這取決於你的圖像的寬度。