cancel
Showing results for 
Search instead for 
Did you mean: 

changing the background color of a cell in a grid

Former Member
0 Kudos

I have a grid that hold approximately 750 rows of data. I need to take the value of a cell and compare it to two other cells (upper and lower spec). I tried the below code and placed alerts everywhere in the for loop and outside of it. I get the correct data everywhere possible except when it comes time to coloring the cell. At first I thought it was because the grid was not updated after the loop was completed, but it doesn't seem to the case. Can anyone assist me in getting the cell to change color?

--My code is not allowed to be shown here

Edited by: xMII_Training on Mar 12, 2008 7:08 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Generally, you should never try to do this "client side" if it can be avoided. Create a BLS transaction with a calculated column called "RowColor". In the expression for that column, use something like:

stringif(Value < Min, "red", stringif(Value > Max, "orange","green"))

Then, in your grid, in the color context configuration, use the column name "RowColor", match mode = string, and assign the text "red", "orange", and "green" to three of the rows, and assign the appropriate color.

Rick

Former Member
0 Kudos

Even though this was helpful, I can not use this because I need only the cell to change color. Otherwise, I have a christmas ornament for a grid. I have created a column that shows either red, green, or yello, but like I said, I need it for only the cell not the row. Any suggestions?

Former Member
0 Kudos

Have you tried chnaging cell color using java script .

function colour()

{

var rowcount=document.Display_Grid.getGridObject().getRowCount();

colourRed=document.Display_Grid.createColor("#FC4D4D");

colourGreen=document.Display_Grid.createColor("#51BF51");

colourYellow=document.Display_Grid.createColor("#FEFE63");

for(i=1;i<=rowcount;i++)

{

var dayvalue=document.Display_Grid.getGridObject().getCellValue(i,7);

var days=dayvalue.substring(0,2);

if(days>=3 && days<7)

{

document.Display_Grid.getGridObject().setCellBackgroundColor(i,7,colourYellow);

}

if(days>=7)

{

document.Display_Grid.getGridObject().setCellBackgroundColor(i,7,colourRed);

}

}

}

sriram

Former Member
0 Kudos

I have something similar, but for whatever reason this forum will not allow me to post my code to show you. I will review your code to see if I am missing anything. Thanks!!