SugarCRM 7 — Colour Code Rows based on data values
Posted on Thu 10 July 2014 in Tech
Add this into your recordlist javascript file.
javascript
render_colors : function() {
console.log('here');
$("tr[name^='<YOUR_MODULE']").each(function() { //loop over each row
if($(this).find('div[data-original-title="Out"]').length > 0) { //check value of TD
$(this).find($('td')).each(function() {
$(this).css("background-color", "#FFBABA");
});
} else if($(this).find('div[data-original-title="In"]').length > 0) {
$(this).find($('td')).each(function() {
$(this).css("background-color", "#C3F8B5");
});
} else if($(this).find('div[data-original-title="Withdrawn"]').length > 0) {
$(this).find($('td')).each(function() {
$(this).css("background-color", "#FFCF8F");
});
} else if($(this).find('div[data-original-title="Reserved"]').length > 0) {
$(this).find($('td')).each(function() {
$(this).css("background-color", "#FAFE8E");
});
}
});
}