Use JS link to register a script with the SharePoint list, rewrite the field template, and change the format and style for fields that match the criteria. But there is a problem is, page postback words, JS will not be triggered, do not know how to solve, have to know the message under, thank you.
Add the JS Link in a WebPart or a list
JS link address format as follows, cannot write relative path or absolute path, otherwise alert does not come out.
~sitecollection/siteassets/js/xxxxxx.js
Instance code, the function is, a URL type field, if the text date of the field is displayed in yellow this month, is the next month's display pink, is the last month's display green.
Field type
var mydate = new Date (); var month=mydate.getmonth () +1; (function () {///Create object that has the context information about the field that we want to change it ' s output Render var gatefiledcontext = {}; Gatefiledcontext.templates = {}; GateFiledContext.Templates.Fields = {//Apply the new rendering for priority field on List View "gate_x002 0_4_x0020_due_x0020_dat ": {" View ": Gatefiledtemplate}," Gate_x0020_5_x0020_due_x0020_dat ": { "View": Gatefiledtemplate}, "Gate_x0020_6_x0020_due_x0020_dat": {"View": Gatefiledtemplate}, "gate_x0020_7_ X0020_due_x0020_dat ": {" View ": Gatefiledtemplate}}; SPClientTemplates.TemplateManager.RegisterTemplateOverrides (Gatefiledcontext); })(); This function provides the rendering logic for List view function gatefiledtemplate (CTX) {var gateorgin=ctx. Currentitem[ctx. Currentfieldschema.name]; var gate = ctx. Currentitem[ctx. currentfieldschema.name+ '. Desc ']; if (gate!= "") {var value=parseint (gate.split ('/') [0]); if (value==month+1) {return "<span style= ' Background-color:pink; ' > "+ gate+" </span> "; } else if (value==month) {return "<span style= ' Background-color:yellow ' >" + gate+ "</span>"; } else if (value==month-1) {return "<span style= ' Background-color:green ' >" + gate+ "</span>"; }else{return "<a href= '" +gateorgin+ ">" + gate+ "</a>";; } } }
Effect
The demo above MSDN
https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a
Sharepoint 2013 list using JS Link