内容查询WebPart多列显示

一、首先内容查询部件的Description栏可以填写自己的字段名称,如Created。

二、多列显示:

主要步骤:

1)导出.webpart文件,定制属性CommonViewFields,添加需要显示的字段名称。

2)修改.ItemStyle.xsl 文件来修改展现样式。

2.1、导出内容查询部件:

  点击内容查询Webpart下拉菜单——导出。

  记事本打开.webpart文件,修改属性
  <property name="CommonViewFields" type="string">Title,Text;Modified,DateTime;Created,DateTime</property>

  上面的字段类型可以省去,直接用InternalName,如
  <property name="CommonViewFields" type="string">Title;Modified;Created;Author</property>

  保存修改,然后在添加WebPart界面导入该.webpart文件,添加到页面上。

2.2、修改ItemStyle.xsl

  该文件位于网站根目录下的Style Library 样式库里。

  一个xsl:template是一个样式模板,可以修改已存在的,也可以自己新建一个xsl:template。

  修改<div class="item link-item">这个Div中的内容,在这个里面可以添加HTML标签代码,比如Table,Span等,用来布局。

  通过<xsl:value-of select="@Author" />来读取.webpart文件中的属性配置的CommonViewFields字段。

三、关于OuterTemplate,Style Library 样式库里那些文件的具体作用及含义,可以参看微软MSDN上的一篇文章,很详细:

  http://msdn.microsoft.com/zh-cn/library/bb447557.aspx

<!--Start Custom-->  
<xsl:template name="CustomMonthStyle" match="Row[@Style='CustomMonthStyle']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<div >
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<table border="0" cellpadding="3" width="99%">
<tr>
<td style="190px;">
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a>
</td>
<td>
<xsl:value-of select="@Actual" />
</td>
<td style="110px;">
<xsl:value-of select="@Editor" />
</td>
</tr>
</table>
</div>
</xsl:template>

<xsl:template name="CustomWeekStyle" match="Row[@Style='CustomWeekStyle']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<div >
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<table border="0" cellpadding="3" width="99%">
<tr>
<td style="190px;">
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a>
</td>
<td style="100px;">
<xsl:value-of select="@Plan" />
</td>
<td>
<xsl:value-of select="@Actual" />
</td>
<td style="110px;">
<xsl:value-of select="@Editor" />
</td>
</tr>
</table>
</div>
</xsl:template>
<!--End Custom-->
原文地址:https://www.cnblogs.com/windy2008/p/2153217.html