有谁知道这是否可以根据显示的某些值向 CellTable 添加一列?
通常使用 addColumn 但仅在 getValue 方法中启用对行属性的访问。我需要更早地获得此访问权限,以决定向列添加一些值或将其留空。
有谁知道这是否可以根据显示的某些值向 CellTable 添加一列?
通常使用 addColumn 但仅在 getValue 方法中启用对行属性的访问。我需要更早地获得此访问权限,以决定向列添加一些值或将其留空。
The answer is to write custom cell class that extends the appropriate cell class (provided with GWT). Then in render method the column's content might be empty or not depending on the value of displayed/rendered object. E.g.
private class VersionCell<T> extends ActionCell<MovieDTO> {
public VersionCell(String text, Delegate<MovieDTO> delegate) {
super(text, delegate);
}
@Override
public void render(MovieDTO m, Object key, SafeHtmlBuilder sb) {
if (m != null && m.getId() != -1) {
super.render(m, key, sb);
} else if (m != null && m.getId() == -1) {
sb.append(new SafeHtmlBuilder().appendHtmlConstant("").toSafeHtml());
}
}
}