根据列值更改Sharepoint中的文本颜色. [英] Changing Text color in Sharepoint based on column value.
本文介绍了根据列值更改Sharepoint中的文本颜色.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为更改已完成"的列.如果该值为是",则返回"0".我希望文字颜色为绿色,并且文字颜色为否".红色.该列是一个复选框,是/否.
I have a column called "Change Completed". If the value is "Yes" I want the text color to be green and "no" red. The column is a checkbox Yes/No column.
推荐答案
您可以通过JSLink覆盖字段渲染格式.
https://www.codeproject.com/Articles/620110/SharePoint -客户端侧渲染列表视图
按如下所示创建一个JavaScript文件(将文件更新为您的归档静态名称).
(function () {
'use strict';
var CustomCtx = {};
/**
* Initialization
*/
function init() {
CustomCtx.Templates = {};
CustomCtx.Templates.Fields = {
// update ChangeCompleted as your filed static name
'ChangeCompleted': {
'View': customDisplay
}
};
// Register the custom template
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(CustomCtx);
}
/**
* 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>" + currentVal + "</div>";
var
f =
(el); 如果(currentVal ==是"){
(el); if (currentVal == "Yes") {
这篇关于根据列值更改Sharepoint中的文本颜色.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文