Change style cell with conditions in the row

Hi,

I want to change a cell’s bakground color if two condition are in the row (there is 3 possible color).
I managed several way to do it but it doesn’t work. :frowning:

What do you think about this :question: :

mygrid.parse(data,“json”);
mygrid.forEachRow(function(id){
mygrid.cells(id,5).setBgColor("#77AE16");
if ((mygrid.cells(id,0).value==“0”) && (mygrid.cells(id,2).value > date)){
mygrid.cells(id,5).setBgColor("#C70C44");
}
if ((mygrid.cells(id,0).value==“0”) && (mygrid.cells(id,2).value == date)){
mygrid.cells(id,5).setBgColor("#FFCC00");
}
});

Thanks for your help,

LC

Try to correct your code in such way:

mygrid.parse(data,"json"); mygrid.forEachRow(function(id){ mygrid.cells(id,5).setBgColor("#77AE16"); if ((mygrid.cells(id,0).getValue()=="0") && (mygrid.cells(id,2).getValue()> date)){ mygrid.cells(id,5).setBgColor("#C70C44"); } if ((mygrid.cells(id,0).getValue()=="0") && (mygrid.cells(id,2).getValue()== date)){ mygrid.cells(id,5).setBgColor("#FFCC00"); } });

Thank you! It works perfectly, I would have to think this