I have a CDE dashboard and onve of my tables has cells that I want to change background colors based on comparing two cells. The javascript below works well and changes the background as wanted, however it gets rid of the number formatting of %.2f when it loads the table so I end up with many values that have several decimals and no more comas. any advice in formatting this would be great.
function f(){
this.setAddInOptions("colType","formattedText",function(state){
if(state.colIdx === 1){
var rev = state.tableData[state.rowIdx][1];
var budgetRev = state.tableData[state.rowIdx][2];
if(rev >= budgetRev){
return { textFormat: function(v, st) {
return "<div style='background:green;'>"+v+"</div>"; } };
}
else
return { textFormat: function(v, st) {
return "<div style='background:red;'>"+v+"</div>"; } };
}
});
}