Does anybody know if this is possible to add a column to CellTable depending on the some value od displayed row?
Normally addColumn is used but the access to row properties is enabled only in getValue method. I need to gain this access earlier to decide either to add some value to column or lewave it blank.
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());
}
}
}