• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
阿斯普洛斯
博客园    首页    新随笔    联系   管理    订阅  订阅
拆分SharePoint 2013 中CreatedModifiedInfo 的时间

最近在自定义DisForm.aspx页面时 发现 创建时间信息无法进行拆分,人事MM只想要修改时间,去掉创建人,创建时间和修改人。

于是我的重新研究下在SPD里面如何去拆分这个时间。

在详情页面上找到的时间信息是如下控件。(默认的DisForm页面没有,这里我是新建了一个列表显示页面)

<SharePoint:CreatedModifiedInfo Visible="false" ControlMode="Display" runat="server"/>

其实就这个东东。但是在转换成html的时候会变成个table,所以我们要分析下里面有什么东西。

问了下其他人,列表的基本模板可以在C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES

的DefaultTemplates.ascx下找到具体对应的数据绑定,查找 CreatedModifiedInfo 大概在485行左右。

<SharePoint:RenderingTemplate id="CreatedModifiedInfo" runat="server">
    <Template>
        <table cellpadding="0" cellspacing="0">
          <tr><td nowrap="nowrap" class="ms-descriptiontext" id="onetidinfoblock1">
                <SharePoint:FormAuthorEditorFormattedString
                    UserOnlyFormatText="<%$Resources:wss,form_createdby_user%>"
                    AppOnlyFormatText="<%$Resources:wss,form_createdby_app%>"
                    UserAppFormatText="<%$Resources:wss,form_createdby_user_app%>"
                    IsAuthorField="true"
                    runat="server">
                    <SharePoint:FormField ControlMode="Display" FieldName="Created" DisableInputFieldLabel="true" runat="server"/>
                    <SharePoint:FormField ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>
                    <SharePoint:CreationType runat="server"/>
                    <SharePoint:FormAppInfo ControlMode="Display" FieldName="AppAuthor" runat="server" />
                </SharePoint:FormAuthorEditorFormattedString>
            </td></tr>
            <tr><td nowrap="nowrap" class="ms-descriptiontext" id="onetidinfoblock2">
                <SharePoint:FormAuthorEditorFormattedString
                    UserOnlyFormatText="<%$Resources:wss,form_modifiedby_user%>"
                    AppOnlyFormatText="<%$Resources:wss,form_modifiedby_app%>"
                    UserAppFormatText="<%$Resources:wss,form_modifiedby_user_app%>"
                    IsAuthorField="false"
                    runat="server">
                    <SharePoint:FormField ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>
                    <SharePoint:FormField ControlMode="Display" FieldName="Editor" DisableInputFieldLabel="true" runat="server"/>
                    <SharePoint:FormAppInfo ControlMode="Display" FieldName="AppEditor" runat="server" />
                </SharePoint:FormAuthorEditorFormattedString>
            </td></tr>
        </table>
    </Template>
</SharePoint:RenderingTemplate>

这时,可以发现这个空间也是由许多数据绑定而成,例如

<SharePoint:FormField ControlMode="Display" FieldName="Created" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormField ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>

上面的代码是显示创建时间和创建人的。
我们回到原来的详细页面设计下。将

<SharePoint:FormField ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>

复制到需要显示的位置。

<tr>
    <td width="190px" valign="top" class="ms-formlabel" style="display:none">
                                        
    <H3 class="ms-standardheader">
    <nobr>标题</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody" style="font-family:微软雅黑;font-weight:bolder;font-size:20px;text-align:center">
                                        
    <xsl:value-of select="@Title"/>
    </td>
</tr>
<tr>
    <td colspan="2" width="400px" valign="top" class="ms-formbody" style="font-family:微软雅黑;font-size:12px;text-align:center">
<SharePoint:FormField FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
</td> </tr> <tr> <td width="190px" valign="top" class="ms-formlabel" style="display:none"> <H3 class="ms-standardheader"> <nobr>Content</nobr> </H3> </td> <td width="400px" valign="top" class="ms-formbody"> <xsl:value-of select="@Content" disable-output-escaping="yes"/> </td> </tr>

具体显示的效果如下

 搞定~

 收工!

 

posted on 2014-10-15 09:38  六指狂魔肉球猫  阅读(730)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3