:: Forum >> Version 2 >>

Change background color of a grid based on individual element value

Hi,


Im using ActiveWidgets version 2.5.5. The values required by the grid are provided in a .csv file which is already preprocessed. I'm trying to colour individual elements based on the values obtained from the .csv file.

How do i go about doing this? Any help would be appreciated.

Rash
Tuesday, February 9, 2010
This applies to rows :
/javascript.forum.10823.5/b4-bug-when-coloring-a.html
And you can do the same for cells:
<script>
var 
obj = new AW.UI.Grid;
obj.setCellData(function(colrow){return col "." row});
obj.setHeaderText("header");

obj.setColumnCount(10);
obj.setRowCount(10);

obj.setCellEditable(true);

// add new cell property for background color
obj.defineCellProperty("bgColor", function(colrow){

  
// lets say we check the text from any cell
  
var text this.getCellText(colrow);

  var 
cellColor 'none';
  if (
text 2) {
    
cellColor "#00FF00";
  }
  if (
text 4) {
    
cellColor "red";
  }
  if (
text >= 200){
    if (
text <=450){
      
cellColor "yellow";
    }
  }
  return 
cellColor;
}); 

// assign rowBackground to row template style
obj.getCellTemplate().setStyle("background", function(){
return 
this.getCellProperty("bgColor");
});  

obj.onCellValidated = function(textcolrow){
var 
template this.getCellTemplate(col,row);
setTimeout(function(){
template.setStyle("background"template.getCellProperty("bgColor"));
  }, 
150);


    
document.write(obj);
</
script
Tuesday, February 9, 2010

Post a reply:

Text:
Name:

Back to support forum

Forum search