Hi, can anyone please help me with this following problem.
I want to change the font color of a row in a table to red whenever some condition is satisfied.
How can i do that?
Please help ASAP.
Use
CellStyleGenerator.
There are many post on this topic on forum, eg.
setCellStyleGenerator - specific style according to cell value
Thankyou. It worked fine.
table.setCellStyleGenerator(new Table.CellStyleGenerator() {
private static final long serialVersionUID = 1L;
@Override
public String getStyle(Table source, Object itemId,
Object propertyId) {
// TODO Auto-generated method stub
if (propertyId == null) {
// Styling for row
Item item = table.getItem(itemId);
String reason = (String) item.getItemProperty(
"Reason").getValue();
if (reason.endsWith("Invalid")) {
return "highlight-darkred";
} else {
return null;
}
} else {
// styling for column propertyId
return null;
}
}
});