3.2.0

How to change color for a specific cell in grid

Hi,

I have values ("Finished", "Error", "Running") in one column "Status"

If the values in the Status Column is Error, then I want it to show in Red Font and Back Ground Color as red.

How do I do this?

I am new to this grid stuff.

Please help

Regards
Kiran
Kiran I S S
October 14,
Are you using 1.0 or the Beta of 2.0?
Jim Hunter
October 15,
activewidgets-grid-1.0-gpl.zip file I downloaded.

October 18,
I think I am using 1.0 as the zip file name is activewidgets-grid-1.0-gpl.zip

Regards
Kiran
Kiran I S S
October 18,
for V1:
function myColor(){
var color;
var value =this.getItemProperty("text"); 
if(value=="finished")
color="yellow";
else if(value=="Error")
color="red";
else
color="green";
return color;
}
obj.getColumnTemplate(col).setStyle("property",myColor);
Vipin
October 20,
Hi there could someone please explain the above in v2 b3
thanks
Alex from Sydney
December 21,
I did a quick test of this and it seems to work

function myColor(v){
var color;
if(v=="finished")
color="yellow";
else if(v=="Error")
color="red";
else
color="green";
return color;
}

for (x=0;x<obj.getRowCount();x++)
{
obj.getCellTemplate(0,x).setStyle("color", myColor(obj.getCellText(0, x)));
}

somehow I bet you don't want red font on a red background like the original post wanted.
Jim Hunter
December 21,
Thanks for the reply Jim,
Is there a way to do this for the whole grid. I mean like a myColor Function that is run everytime the grid is refreshed.
eg: the result would look like this
...
myColor(c,r){
...
}
...
obj.getCellTemplate().setStyle("color",myColor(col,row))
...

thanks again.
Alex from Sydney
December 21,
First, I would not think about running a function that traverses each cell every time someone hits refresh. It would only need to be run when data changes. Run it once when you first assign the data then call it for the cell that changes if data is edited. The sample above was restricted to a single colimn, just remove the restriction to run it over the entire grid. The color function remains the same.
Jim Hunter
December 22,
Hi folks:
This is interesting. I have run into almost a similar situation. Here it is :
Based on a cell value - "Close"/"Open" in a row, I need to change the background color and/or the font color of all the cells in that row. And, is there a way to change the font color of specified cells as well based on the above condition?.
Please let me know how to go about doing this.
May I request you to send your soultion to my e-mail ID - avramreddy@gmail.com (if it is ok).

Appreciate your repsonse.

Thank you,
Venkat.
Venkat
December 9,

This topic is archived.

See also:


Back to support forum