I would like to change the background color of a grid cell based on a grid cell value. For example, I have a grid cell with RGB value of #F340D8″. I am referring to the following code:
// if nothing set in 'op' and 'value', it will set column formatting for all cell
$f = array();
$f["column"] = "invdate";
$f["css"] = "'background-color':'#FBEC88', 'color':'green'"; // must use (single quote ') with css attr and value
$f_conditions[] = $f;
This works as expected but I would like to reference the background color to a field. I was hoping that something like the following would work.
$f["css"] = "'background-color':'#{rgb}', 'color':'green'";
However, this does not work. Am I doing something wrong or is this capability not supported?
1 Answers
This can be achieved by some conditional formatting JS code.
Refer this demo code: https://www.gridphp.com/demo/demos/appearance/conditional-format-ext.phps
Line 32: Connects the JS function with load event
Line 137: Shows how to change background color of a cell. And you can refer row data like this.gender in this code.
Your Answer