Is there any way to change the background color for a single cell (not the entire column)? Ideally, I would like to be able to click on the cell and have it cycle through three colors based on value (say, red for zero, green for 1, yellow for 2):
I was thinking about something like this:
grid.attachEvent(“onEditCell”, function (stage, id, ind, value) {
if (stage==0) {
changeCellValueFunction(id, ind);
changeBackgroundColorFunction(id, ind, value);
}
return true;
});
If I am on the right track, the only code that I need help with would be the changeBackGroundColorFunction.
Thanks in advance!
If I am on the right track
onEditCell can be used in such scenario, but it will work only for editable cells, alternatively you can use
mygrid.setOnRowSelectHandler(function(id,ind){
changeCellValueFunction(id, ind);
changeBackgroundColorFunction(id, ind, mygrid.cells(id,ind).getValue());
return true;
},true);
You can set background color of cell as
grid.cells(id,val).setBgColor(value); // you can use getBgColor( to get current color
Or in more flexible way
grid.setCellTextStyle(id,ind,“background-color:red”)