SharePoint 2013 在Discussion board 视图中显示非标准字段的值

本文讲述如何在SharePoint 2013 的Discussion board 视图中显示非标准字段的值。

Discussion board 视图是由15\TEMPLATE\LAYOUTS\sp.ui.discussions.js负责显示的,如果直接在web part里面覆盖JSLink,就会覆盖这个文件的作用。

因此,如果要 在SharePoint 2013 的Discussion board 视图中显示非标准字段的值就需要改动15\TEMPLATE\LAYOUTS\sp.ui.discussions.debug.js

比如你要显示一个myColumn字段,那么就作如下操作:

1. 在这个方法里面加入字段名 SP.UI.Discussions.Helpers.$1f = function SP_UI_Discussions_Helpers$$1f($p0, $p1)

ar $v_2 = ['ID', 'PermMask', 'Created', 'Modified', 'Title', 'FSObjType', 'ContentTypeId', 'FileRef']
=>

 var $v_2 = ['ID', 'PermMask', 'Created', 'Modified', 'Title', 'FSObjType', 'ContentTypeId', 'FileRef', 'myColumn']

2. 更改方法 $2u_0: function SP_UI_Discussions_PostBehavior$$2u_0($p0, $p1)

 $2u_0: function SP_UI_Discussions_PostBehavior$$2u_0($p0, $p1) {
        this.populateFolderMetalineItems($p1);
        $p0.addCssClass('ms-comm-metalineList ms-noList');
        $p0.renderBeginTag('ul');

        // Inorder to display myColumn
        if (this.jsonItem["myColumn"]) {
            $p0.addCssClass("ms-comm-metalineItemSeparator");
            $p0.addCssClass("ms-comm-metalineItem");
            $p0.renderBeginTag("li");
            $p0.write(spMgr.RenderFieldByName(this.$0_0, "myColumn", this.jsonItem, this.$0_0.ListSchema))
            $p0.renderEndTag()
        }
        

        for (var $v_0 = 0, $v_1 = this.$R_0.length; $v_0 < $v_1; $v_0++) {
            if ($v_0 !== $v_1 - 1) {
                $p0.addCssClass('ms-comm-metalineItemSeparator');
            }
            $p0.addCssClass('ms-comm-metalineItem');
            $p0.renderBeginTag('li');
            $p0.write(this.$R_0[$v_0]);
            $p0.renderEndTag();
        }
        $p0.renderEndTag();
    }

3.更改方法 $2y_0: function SP_UI_Discussions_PostBehavior$$2y_0($p0)

$2y_0: function SP_UI_Discussions_PostBehavior$$2y_0($p0) {

        // Inorder to display myColumn
        var myColumn = spMgr.RenderFieldByName(this.$0_0, "myColumn", this.jsonItem, this.$0_0.ListSchema);
        if (myColumn) {
            $p0.addCssClass("ms-metadata");
            $p0.addCssClass("ms-comm-cmdSpaceListItem");
            $p0.renderBeginTag("span");
            $p0.write(replyCount);
            $p0.renderEndTag();
        }        

        $p0.addCssClass('ms-metadata');
        $p0.addCssClass('ms-comm-cmdSpaceListItem');
        $p0.renderBeginTag('span');
        var $v_0 = spMgr.RenderFieldByName(this.$0_0, 'Created', this.jsonItem, this.$0_0.ListSchema);

        $p0.write($v_0);
        $p0.renderEndTag();
    }

4. 使用SharePoint designer 2013 打开该Discussion 列表,编辑其View的源码,搜索JSLink,将JSLink中的sp.ui.discussions.js 改为 sp.ui.discussions.debug.js,保存。

5. 重启IIS

6. 打开Discussion board就可以看到myCloumn字段了。 



你可能感兴趣的:(SharePoint,2013,显示,board,Discussion,视图view,CustomField)