惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
L
LangChain Blog
Y
Y Combinator Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
V
Visual Studio Blog
小众软件
小众软件
月光博客
月光博客
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
美团技术团队
量子位

博客园 - jianyi

SpringBoot - open-in-view 机制分析 w3wp CPU 100%问题解决 ShrePoint 迁移域控 SharePoint online 获取文件版本记录 SharePonit online 列表表单定制 VS2015 ionic 开发环境配置纪要 TFS online build change web.config SharePoint 2016 - 安装QuickFlow2013 EF Migrations error: No connection string named 'MpDb' could be found in the application config file. TFS online 自动部署配置 SharePoint Permission Extension SharePoint暂时禁用事件触发 视图xsl定制之嵌入服务器控件 自定义母版页之列表过滤菜单位置issue fix ListDefinition Tips QuickFlow UI 控件之 NamedFormAttachment SharePoint 2010 GridView/SPGridView完全应用系统样式 QuickFlow-如何通过QFD and ExecuteCode获取其他列表数据 DLL嵌入exe中
自定义View字段表头
jianyi · 2014-06-13 · via 博客园 - jianyi

适用场景:

三个列表进行Join,然后试图上显示ProjectedField,而ProjectedField不支持设置DisplayName.默认只能显示英文名。

join caml如下:

<View>
<Query>
    <OrderBy>
      <FieldRef Name="ID" />
    </OrderBy>
  </Query>
  <ViewFields>
    <FieldRef Name="Attachments" />
    <FieldRef Name="LinkTitle" />
    <FieldRef Name="FirstName" />
    <FieldRef Name="Company" />
    <FieldRef Name="WorkPhone" />
    <FieldRef Name="HomePhone" />
    <FieldRef Name="Email" />
    <FieldRef Name="TuMuLookup" />
    <FieldRef Name="ZhuanYe" />
  </ViewFields>
  <Joins>
    <Join Type="LEFT" ListAlias="TuMu">
      <Eq>
        <FieldRef Name="TuMuLookup" RefType="ID" />
        <FieldRef List="TuMu" Name="ID" />
      </Eq>
    </Join>
    <Join Type="LEFT" ListAlias="ZhuanYe">
      <Eq>
        <FieldRef List="TuMu" Name="ZhuanYeLookup" RefType="Id" />
        <FieldRef List="ZhuanYe" Name="ID" />
      </Eq>
    </Join>
  </Joins>
  <ProjectedFields>
    <Field List="ZhuanYe" Type="Lookup" Name="ZhuanYe" ShowField="Title" />
  </ProjectedFields>
  <XslLink Default="TRUE">main.xsl</XslLink>
  <RowLimit Paged="TRUE">30</RowLimit>
  <Toolbar Type="Standard" />
</View>

解决方法:

采用自定义xsl来解决。

1)在layouts/xsl下增加一个xsl文件:xsl_zhuanye.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">
  <xsl:output method="html" indent="no" encoding="uft-8" />
  <xsl:include href="/_layouts/xsl/main.xsl" />
  <xsl:include href="/_layouts/xsl/internal.xsl" />
  <xsl:decimal-format NaN="" />
  <xsl:template match="/">  
    <xsl:apply-templates mode="RootTemplate" select="$XmlDefinition" />        
    <hr/>
  </xsl:template>
  <xsl:template name="FieldRef_header.ZhuanYe" match="FieldRef[@Name='ZhuanYe']" mode="header">
    <th nowrap="" scope="col" onmouseover="OnChildColumn(this)" class="ms-vh2">
      <div class="ms-vh-div">   
        专业
      </div>
    </th>
  </xsl:template>
</xsl:stylesheet>

备注:<xsl:template match="/"> 模板可以删掉

2)修改列表webpart属性,这是其Xsl链接为/_layouts/xsl/xsl_zhuanye.xsl

3)iisreset清除视图xsl缓存。