This will give greater visibility to a field that is important to understand at a glance such as a status field and adjusting the highlight color based on the current status.
The JS
This function allows us to identify the details view label body and set a background color value
//Change Label Body Background Color
function changeFieldColor(field, color_map) {
var child_field = $(field).find(".kn-detail-body");
var value = child_field.text();
if (color_map[value]) {
$(child_field).css({
"background-color": color_map[value].background_color,
color: color_map[value].color
});
}
}
This function allows us to identify a table field and set a background color value
//Change Table Value Background Color
function changeTableFieldColor(field, color_map) {
var fields = $(field);
fields.each(function() {
var value = this.innerText;
if (color_map[value]) {
$(this).css({
"background-color": color_map[value].background_color,
color: color_map[value].color
});
}
});
}
We set variables for each combination of background and text colors we want based on field values