I had trouble finding a concrete example of how to use setRowStyleGenerator, so after figuring it out I thought I would share it:
In this example I am looking for a string within a specific column’s cell within a row of a grid, then add the class name “red” to the row.
[code]
this.setRowStyleGenerator(new RowStyleGenerator() {
public String getStyle(Grid.RowReference row) {
if (row.getItem().getItemProperty("YOUR_COLUMN_NAME").getValue() != null ) {
String testString1 = "my string to find";
Object testObj1 = row.getItem().getItemProperty("YOUR_COLUMN_NAME").getValue();
if (testObj1.toString().contains(testString1)) {
return "red"; //adds class="red" to this row, in css add: .red td {background:red}
}
}
return null;
}
});
[/code]