3.0 beta 2

changing cell color + cell selection color


I'm working on a grid that has cells with different colors. I'm doing it in the following way:
obj.getCellTemplate(i, j).setStyle("background-color", "#FFA500!important")

But when I select a cell that have the color changed, it doesn't get highlighted. The cells that I don't chnage the color are highlighted normally.

Is there anyway to do it work? I try to put some code inside the fucntion calculateCellState to alter the background-color, but it didn't work ...

By the way, I'm working in an alternate selection mode where it is possible to select multiple cells. If anybody is interested, I can send the parts of the code that I've changed.

Roberto Barra
February 2,
Ok, I find a way to make it work ... it's not pretty, but it works.

I changed the function selectCell(c, r) in the follwoing way:

var colorBgB = document.getElementById(
        this.getCurrentRow()).getId()).style.backgroundColor = colorBgB;


for (i = 0; i < selCells.length; i = i + 2)
   var cTmp = selCells[i];
var rTmp = selCells[i + 1];
   if (this.getCellSelected(cTmp, rTmp))
      this.setCellSelected(false, cTmp, rTmp);
      var colorBg = document.getElementById(obj.getCellTemplate(cTmp, rTmp).getId()).title;
      document.getElementById(obj.getCellTemplate(cTmp, rTmp).getId()).style.backgroundColor = colorBg;
selCells = new Array();

var colorBg = document.getElementById(obj.getCellTemplate(c, r).getId()).style.backgroundColor;
document.getElementById(obj.getCellTemplate(c, r).getId()).title = colorBg;
document.getElementById(obj.getCellTemplate(c, r).getId()).style.backgroundColor = '#122334';

I saved the value of the old color of the cell in the title attribute. I don't think it'll be used for some ohter thing.

selCells must be declared somewhere.

That's it.
Roberto Barra
February 2,

This topic is archived.

See also:

Back to support forum


Version 2

Looking for AW 2.6 ?
The old site is here.