GridX set class for row (based on row data)

1.3k Views Asked by At

Is it possible for GridX to set the class for the given row, based on the data in that row?

I'd like to show with special color the rows that were added or changed. That information will be stored in the object as a special field.

As for now, I've found only, how to individualize rendering of cells (using decorator, or overwriting setCellValue).

1

There are 1 best solutions below

0
On

I think I found the answer here

http://dojo-toolkit.33424.n3.nabble.com/formatter-o-decoration-in-GridX-td4000793.html

Cell 7 is checked for the value 'ok'.

dojo.connect(grid.body, 'onAfterRow', function(row){
    var r = row.data();
    if(r[6] !== 'ok'){
        domClass.remove(row.node(), "gridxRowOdd");
        row.node().style.backgroundColor = 'red';
    }
});

or if empty cells should not get coloring:

dojo.connect(grid.body, 'onAfterRow', function(row){ 
var r = row.data(); 
var node = row.node(); 
if(r[6] !== 'ok'){ 
    var cells = dojo.query('.gridxCell', node); 
    var c = cells.length; 

    for(var i = 0; i < c; i++){ 
        cells[i].style.backgroundColor = 'red'; 
    } 
} 

} 
});

Because dojo.connect is old and somewhat? deprecated. Use aspect.after:

aspect.after(grid.body, 'onAfterRow', lang.hitch(this, function (row) {
var item = row.rawData();
if (item[6] !== '') {
   domClass.remove(row.node(), "gridxRowOdd");
   row.node().style.backgroundColor = 'red';
}
}), true);