Can you change the grid cell background color based on a grid cell value?

QuestionsCan you change the grid cell background color based on a grid cell value?
Mike Fischer asked 1 year ago

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
Abu Ghufran Staff answered 1 year ago

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.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

12 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?