GWT:如何更改GWT Celltable中的行颜色
问题描述:
我在GWT中有一个celltable,我可以通过这个改变特定列的颜色。
i have a celltable in GWT, I can change color of a specific column by this
celltable.addColumnStyleName(4, "bluetext");
但是我怎样才能改变颜色的第3行
but how can i change for example color of row No 3
谢谢
Thanks
答
您必须提供 RowStyles
返回每行的css类名称的对象。所以,为一行设置一个特定的颜色,你必须用这种颜色定义一个css类,然后让你的 RowStyles
对象返回相关的类行。
You have to provide a RowStyles
object that returns css class names for each row. So, to set a particular color for a row, you'd have to define a css class with that color, and then cause your RowStyles
object to return that class for the relevant rows.
我想你可以用 cellTable.setRowStyles
或类似的东西来设置它。
I think you set this with cellTable.setRowStyles
or something similar.
cellTable.setRowStyles(new RowStyles<T>() {
@Override
public String getStyleNames(T rowObject, int rowIndex) {
if (rowIndex == 3) {
return "bluetext";
} else {
return "normaltext";
}
});