sharepoint - 在 SharePoint 文档库中查看文件属性而不是文件
问题描述
我在 SharePoint Online 上有一个文档库,其中包含许多元数据列。这些列不适合屏幕上的单个视图,因此我希望用户在下载文件之前先查看文件的属性。
有没有办法改变 SharePoint 库的行为,确保用户在单击文件名时首先查看文件属性?
PS:我知道我可以使用列表,但是在加载了大约 10000 个文档后,我决定将它用作最后的手段。谢谢你。
解决方案
通过CSR自定义 LinkFilename 字段。
示例代码:
(function () {
'use strict';
var CustomWidthCtx = {};
/**
* Initialization
*/
function init() {
CustomWidthCtx.Templates = {};
CustomWidthCtx.Templates.Fields = {
'LinkFilename': {
'View': customDisplay
}
};
// Register the custom template
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(CustomWidthCtx);
}
/**
* Rendering template
*/
function customDisplay(ctx) {
var currentVal = '';
//from the context get the current item and it's value
if (ctx != null && ctx.CurrentItem != null)
currentVal = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
var el = "<div class='ms-vb itx' id='" + ctx.CurrentItem.ID + "' app='' ctxname='ctx37'><a title='" + ctx.CurrentItem._ShortcutUrl + "' class='ms-listlink ms-draggable' aria-label='Shortcut file' onfocus='OnLink(this)' href='/Doc4/Forms/EditForm.aspx?ID=" + ctx.CurrentItem.ID + "' target='_blank' DragId='17'>" + ctx.CurrentItem.FileLeafRef + "</a></div>";
// Render the HTML5 file input in place of the OOTB
return el;
}
// Run our intiialization
init();
})();
推荐阅读
- reactjs - React:如何在包装的组件中获取 HOC 的状态?我可以举一个简单的例子来说明 HOC 是如何传递这样一个值的吗?
- sql - Postgres中以毫秒为单位的下采样时间戳
- hibernate - Spring Boot 没有从 data.sql 文件中插入数据?
- javascript - jQuery插件方法返回对象而不是值
- javascript - 对 React setState 的多次更新导致重新渲染地狱和阻塞
- html - 图片不显示在html中
- javascript - 如何在完成表格后下载图像,但表格是使用 wordpress 上的插件完成的
- c++ - 标准库容器最简单、性能差的哈希类是什么?
- angular - 如何从Angular中的数组初始化路由?
- android - RecyclerView 流过屏幕