Thursday, June 21, 2012

Re: how to set the row color of CellTable based on values in a column

table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
singleSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
@Override
public void onSelectionChange(SelectionChangeEvent event) {
// set RowStyles
table.setRowStyles(new RowStyles<Log>(){
@Override
public String getStyleNames(Log row, int rowIndex) {
if (row.getLog_no()==singleSelectionModel.getSelectedObject().getLog_no()){
return null; // the row is highlighted, use the default style
}else if(row.getSeverity_cd().equalsIgnoreCase("W ")){
return "warning";
}else if (row.getSeverity_cd().equalsIgnoreCase("C ")){
return "critical";
}else if (row.getSeverity_cd().equalsIgnoreCase("10")){
return "ten";
}else if (row.getSeverity_cd().equalsIgnoreCase("20")){
return "twenty";
}else if (row.getSeverity_cd().equalsIgnoreCase("30")){
return "thirty";
}else if (row.getSeverity_cd().equalsIgnoreCase("40")){
return "forty";
}else
return null;
}
});

}});

table.setSelectionModel(singleSelectionModel);

if the row is selected, I set its RowStyles to null as shown in attached file output.txt, this give me  the output as attached in output.png.

But I still do not know why when I return null in CellTable.setRowsStyles, the default style will be used (although this is what I want)!!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/48izASvcH04J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment