救命啊各位!我的共享点页面中有一个选择字段,其中包含如下选项:
(1) Go
(2) Warning
(3) Stop
现在,我希望它以图标而不是文本的形式出现在列表中。我有一个可以工作的 jquery 脚本,但是在所有列表中搜索包含的文本需要很长时间,而且无论如何使用 xsl 会更好,因为它会在显示之前呈现。
那么我怎样才能在 xsl 中完成这个呢?这是据我所知,因为我只学习 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">
<!-- Convert the Scope Field into an icon -->
<xsl:template match="FieldRef[@Name='Scope']">
<xsl:param name="thisNode" select="."/>
<xsl:choose>
<xsl:when test="$thisNode/@Scope='(1) Go'">
<td class="statusRating1"></td>
</xsl:when>
<xsl:when test="$thisNode/@Scope='(2) Warning'">
<td class="statusRating2"></td>
</xsl:when>
<xsl:when test="$thisNode/@Scope='(3) Stop'">
<td class="statusRating3"></td>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$thisNode/@Scope" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
这是我要应用的css:
.statusRating1{background-image: url("/_layouts/custom/images/go.png"); }
.statusRating2{background-image: url("/_layouts/custom/images/warning.png"); }
.statusRating3{background-image: url("/_layouts/custom/images/stop.png"); }
现在,我已经尝试过使用和不使用mode="Choice_body"
or mode="MultiChoice_body
and even Text_body
,并且也尝试过添加 <xsl:apply-templates />
,但它似乎从来没有挂钩。该列明确命名为“范围”。也许我只需要添加正确的模式?
在萤火虫中,我可以看到从未添加过该类。
[更新]我注意到在我以这种方式使用模板的其他地方,除非模板mode
定义正确,否则模板永远不会“采用”。但是,我用谷歌搜索了世界各地,找不到mode
用于选择字段的权利。我什至为此创建了一个问题,在这里。此外,使用thisNode
来自Microsoft 的示例,您可以在其中非常轻松地修改字段类型(此处选择字段除外)。