您的位置:首页 > 其它

[SharePoint 2010] 自定义字段类型开发(二)

2013-11-25 15:01 295 查看
在SharePoint 2010中实现View Action Button效果。

http://www.sharepointblogs.be/blogs/vandest/archive/2008/06/20/view-action-button.aspx

1. 创建自定义字段类ViewActionButton 继承自 SPTextField

<?xml version="1.0" encoding="utf-8"?>
<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">

<xsl:template match ="FieldRef[@FieldType='ViewActionButton']" mode="Text_body">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="ActionURL" select="current()/@ActionURL" />
<xsl:variable name="Format"  select="current()/@Format" />
<xsl:variable name="CssClass"  select="current()/@CssClass" />

<xsl:choose>
<xsl:when test="$Format='Button'">
<input type="button">
<xsl:attribute name="class">
<xsl:value-of select="$CssClass"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="$thisNode/@Name"/>
</xsl:attribute>
<xsl:attribute name="onclick">
javascript:window.location=STSPageUrlValidation('$ActionURL?ID=$thisNode/@ID&List=$List');
</xsl:attribute>
</input>
</xsl:when>
<xsl:otherwise>
<a target="_blank">
<xsl:attribute name="class">
<xsl:value-of select="$CssClass"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$ActionURL" />?ID=<xsl:value-of select="$thisNode/@ID" />&List=<xsl:value-of select="$List" />
</xsl:attribute>
<xsl:value-of select="current()/@DisplayName"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


fldtypes_ViewActionButton.xsl
5. 下载

ViewActionButton.zip
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: