CSR: how to default value render
-
18-02-2021 - |
문제
Tell me how to set the default display of an element? Didn't find any good example anywhere on how to return the style and value of a list item to its default?
(function () {
var linkFilenameFiledContext = {};
linkFilenameFiledContext.Templates = {};
linkFilenameFiledContext.Templates.Fields = {
"LinkFilename": { "View": linkFilenameFiledTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFilenameFiledContext);
})();
function linkFilenameFiledTemplate(ctx) {
var fileRef = ctx.CurrentItem.FileRef;
var encoded = encodeURIComponent(fileRef);
var url = "http://sp-test/sites/test";
var FileLeafRef = ctx.CurrentItem.FileLeafRef;
var type = ctx.CurrentItem.File_x0020_Type;
var LinkFilename = ctx.LinkFilename;
var Project = ctx.CurrentItem.Project;
if(Project == "Active" && ctx.CurrentItem.File_x0020_Type == ""){
return "<b><span><a href=" + url + encoded + ">" + FileLeafRef + "</a></span></b>";
} else {
return //value and item style default?????
}
}
해결책
You could add value and style directly like,just like writing html:
<b><span style='add css you want'><a href=" + url + encoded + ">" + FileLeafRef + "</a></span></b>
List View CSR introduction: Client Side Rendering: List Views
Updated:
You could try to get it in ctx.ListData.Row.
제휴하지 않습니다 sharepoint.stackexchange