:: Forum >>

changing cell color + cell selection color

Hi

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.

Bye!
RGB
Roberto Barra
Thursday, February 2, 2006
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.getCellTemplate(
            this.getCurrentColumn(),
            this.getCurrentRow()).getId()).title;
document.getElementById(
    this.getCellTemplate(
        this.getCurrentColumn(),
        this.getCurrentRow()).getId()).style.backgroundColor = colorBgB;

this.setCurrentColumn(c);
this.setCurrentRow(r);
this.setSelectedColumns([c]);
this.setSelectedRows([r]);

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.
RGB
Roberto Barra
Thursday, February 2, 2006

This topic is archived.


Back to support forum

Forum search