3.2.0

Coloring individual cells V1

I used...

obj.getColumnTemplate(0).setStyle("background-color","red");

...to color an individual column, but is there a way to color an individual cell? I've replaced 'Column' with 'Row' and it colored the entire grid, and I replaced it with 'Cell' but that never even worked.

Thanks in advance,

BenjaminS
February 10,
Oops, this is supposed to be in version 1 category :P
BenjaminS
February 10,
I found a solution: (mainly from metacove's code in a recent post).
My XML file had the hex number in it, so I used indexOf() and substring to get the color value.
(ie: <time1>#1221FFDIR. SP.&lt;br&gt;Temp.</time1> would colour the cell #1221FF)

Then I used:


var cellColours = function() {
var cellContent = this.getItemProperty("text");
position = cellContent.indexOf('#');
if(position==-1) return "white";
var colour=cellContent.substring(position,7);
return colour;
}

for(i=0;i<obj.getColumnCount(); i++)
obj.getColumnTemplate(i).setStyle("background-color",cellColours);
BenjaminS
February 10,

This topic is archived.

See also:


Back to support forum