Change Column background color and text color
المحلول
To achieve this type of functionality, you can use Client Side Rendering in SharePoint 2013.
You can use below code for the same:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var rows = ctx.ListData.Row;
for (var i = 0; i < rows.length; i++)
{
var status = rows[i]["YourColumnName"]; //Replace with your column name
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
//To Change the Background color of complete row
row.style.backgroundColor = "#FFFF00"; //Yellow Color - You can change the color according to your requirements.
//To Change the Background color of Particular cell
var cell = row.cells[9]; //Replace 9 with your columns cell number
cell.style.backgroundColor = "#FFFF00";
}
}
});
});
Check my answer given here to know how to set the JSLink property of your Web Part:
Color Coding List Item by Web Part based on value
نصائح أخرى
You can achieve this using JSLINK in SharePoint 2013. Here are some articles which will help you in applying JSLink. Try it and if you have any issues or doubts in that, I will be happy to help.
- Using JSLink to color code column (make sure you select the code in answer)
- Format Status Column using JSLink
You will have to change some lines of code to fit your requirement. Your requirement is simpler than the ones in link. So once you understand how it is rendered, you can apply your logic. Hope it helps.
لا تنتمي إلى sharepoint.stackexchange