SharePoint 2010列表视图webpart XSLT

时间:2012-05-17 06:45:03

标签: sharepoint xslt sharepoint-2010

我尝试使用XSLT创建列表视图Web部件的自定义显示。我已链接到xsl文件并使用以下代码填充它:

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">    
<xsl:template match="/">
    <table class="ms-listviewtable" cellspacing="0" cellpadding="1" width="100%" border="0">     
        <thead>
           <th class="ms-vh2">Title</th>
           <th class="ms-vh2">Status</th>
           <th class="ms-vh2">Percent Complete</th>
        </thead>      
    </table>
</xsl:template>
<xsl:template match="Row">
    <tr>
        <td> 
            <xsl:value-of select="@Title"/> 
        </td> 
        <td> 
            <xsl:value-of select="@Status"/> 
        </td> 
        <td> 
            <xsl:value-of select="@PercentComplete"/> 
        </td> 
    </tr>
</xsl:template>

此刻只显示标题。有人可以指出我做错了吗?

先谢谢

1 个答案:

答案 0 :(得分:4)

您需要致电Row模板。在编码术语中,您实际上有一个从未被Main调用的Row方法。

尝试将xsl:apply-templates添加到根模板:

<xsl:template match="/">
    <table class="ms-listviewtable" cellspacing="0" cellpadding="1" width="100%" border="0">     
        <thead>
           <th class="ms-vh2">Title</th>
           <th class="ms-vh2">Status</th>
           <th class="ms-vh2">Percent Complete</th>
        </thead>
        <xsl:apply-templates select="/dsQueryResponse/Rows/Row"/>
    </table>
</xsl:template>