:: Forum >>
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 :
http://www.activewidgets.com/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(col, row){return col + "." + row});
obj.setHeaderText("header");
obj.setColumnCount(10);
obj.setRowCount(10);
obj.setCellEditable(true);
obj.defineCellProperty("bgColor", function(col, row){
var text = this.getCellText(col, row);
var cellColor = 'none';
if (text < 2) {
cellColor = "#00FF00";
}
if (text > 4) {
cellColor = "red";
}
if (text >= 200){
if (text <=450){
cellColor = "yellow";
}
}
return cellColor;
});
obj.getCellTemplate().setStyle("background", function(){
return this.getCellProperty("bgColor");
});
obj.onCellValidated = function(text, col, row){
var template = this.getCellTemplate(col,row);
setTimeout(function(){
template.setStyle("background", template.getCellProperty("bgColor"));
}, 150);
}
document.write(obj);
</script>
Tuesday, February 9, 2010
This topic is archived.
Back to support forum
Forum search