Grid - Changing cell color based on adjacent cells value

Is it possible to control the background color of a cell based on the cell directly to the right or left of it?



My scenario is as follows: one column contains actual values and a second contains the “ranking” order of those values. I need to color the first ten (rank 1-10) of the values green and the second ten (rank 11-20) in blue. The coloring needs to be present in both columns.



The following function (borrowed from another knowledge base article) changes the color of the rank column:



function eXcell_rank(cell){

if (cell){

this.cell = cell;

this.grid = this.cell.parentNode.grid;

eXcell_ed.call(this);

}

this.setValue=function(val) {

this.setCValue(val);

if (val<=10)

this.cell.style.backgroundColor=“green”;

else if (val<=20)

this.cell.style.backgroundColor=“cyan”;

}

this.getValue=function() {

if (this.cell._clearCell)

return “”;

return this.cell.innerHTML.toString()._dhx_trim();

}

}

eXcell_rank.prototype = new eXcell;



The piece I’m unable to locate in the documentation is how to get the cell immediately left or right of “this.cell”, after which I could write another eXcell function called rankleft or rankright to specify where the ranking column is located.

You can get cell index with var ind=this.cell._cellIndex;