【发布时间】:2017-07-07 18:30:44
【问题描述】:
我正在尝试让条件格式在 Sharepoint 2013 上的列表上工作,我想要它做的是根据输入的内容更改优先级字段中单词的颜色,例如高 = 红色 低 = 绿色 中 = 橙色
我已经尝试了多种方法,并且查看了很多教程,但是由于我只有 JS 和 CSR 的基本知识,我发现它很难,我知道要应用 JS 文件到 Web 部件,我必须在 Web 部件编辑器的杂项区域中链接文件的地址位置,这只是我遇到问题的代码。
这是我目前所拥有的
(function () {
var priorityFiledContext = {};
priorityFiledContext.Templates = {};
priorityFiledContext.Templates.Fields = {
"Priority": { "View": priorityFiledTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(priorityFiledContext);
})();
function priorityFiledTemplate(ctx) {
var priority = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
switch (priority) {
case "(1) High":
return "<span style='color :#f00'>" + priority + "</span>";
break;
case "(2) Normal":
return "<span style='color :#ff6a00'>" + priority + "</span>";
break;
case "(3) Low":
return "<span style='color :#cab023'>" + priority + "</span>";
}
}
【问题讨论】:
-
你的代码好像是这样的:code.msdn.microsoft.com/office/…你能更好地解释你遇到的问题吗?
标签: javascript sharepoint-2013