3.0 beta 2

Row Color Based on Row Data Without Overriding Other Styles

Basically I want to set row color based on a flag in an array, but would still like built-in features like row selection colors to work. I've done something similar to the following but it breaks selected row highlighting. There is one entry in the matchFlag array for each data row in the table (data including match flag is all generated in PHP)

My code is based on this example

var matchFlag [ 0, 1, 0, 0, 0 ];
var obj = new AW.UI.Grid;
obj.setSize(725, 300);
obj.setRowCount(// number of rows from data model);
// create new row property
obj.defineRowProperty("color", function(row){
    var color = "white";
    if(matchFlag[row] == 1) {
        color ="red";
    } else if(row % 2 == 0) {
        color = "#f2f4ff";
    } else if(this.getRowSelected(row)) {
        color = "blue";
    return color;
// link row background to row color property
obj.getRowTemplate().setStyle("background", function(){
    return this.getRowProperty("color");
August 15,
I should add that row selection highlighting is broken with or without the code involving the selected row, I've tried it both ways.
August 15,
Nevermind, I figured out a MUCH easier way to do this by generating the style information in php.
August 15,

This topic is archived.

See also:

Back to support forum


Version 2

Looking for AW 2.6 ?
The old site is here.