问题
I want to know which columns are collapsed & uncollapsed, in vaadin. Is there a listener for this, I could not found?
回答1:
It's not supported out the box. However you could extends Table to support it.
Something like
public class ColumnCollapsedObservableTable extends Table {
private List<ColumCollapsedListener> collapseListeners = new ArrayList<ColumCollapsedListener>();
@Override
public void setColumnCollapsed(Object propertyId, boolean collapsed)
throws IllegalStateException {
super.setColumnCollapsed(propertyId, collapsed);
fireColumnCollapsedEvent(new ColumnCollapsedEvent(this, propertyId, collapsed));
}
public void addColumnCollapsedListener(ColumnCollapsedListener l) {
...
}
public void removeColumnCollapsedListener(ColumnCollapsedListener l) {
...
}
private fireColumnCollapsedEvent(ColumCollapsedEvent event) {
...
}
}
回答2:
Currently (Vaadin 7.7.5 may be also in versions before) there is a ColumnCollapseListener for that.
Table.addColumnCollapseListener(Table.ColumnCollapseListener listener)
EDIT
For uncollapsed events the listener method above will be called again (unfortunately with exact same arguments of the given Event object so that there is no way to make a difference between collapsing and uncollapsing event)
来源:https://stackoverflow.com/questions/23905411/vaadin-table-collapse-column-listener