import com.vaadin.terminal.gwt.client.Util;
public class TableConnector extends AbstractComponentContainerConnector
- implements DirectionalManagedLayout {
+ implements DirectionalManagedLayout, PostLayoutListener {
/*
* (non-Javadoc)
}
public void layoutHorizontally() {
- getWidget().updateWidth();
+ // getWidget().updateWidth();
+ }
+
+ public void postLayout() {
+ getWidget().sizeInit();
}
}
int serverCacheFirst = -1;
int serverCacheLast = -1;
+ private boolean sizeNeedsInit = true;
+
public VScrollTable() {
setMultiSelectMode(MULTISELECT_MODE_DEFAULT);
tFoot.setHorizontalScrollPosition(0);
initialContentReceived = true;
- if (isAttached()) {
- sizeInit();
- }
+ sizeNeedsInit = true;
scrollBody.restoreRowVisibility();
}
if (oldPageLength != pageLength && initializedAndAttached) {
// page length changed, need to update size
- sizeInit();
+ sizeNeedsInit = true;
}
}
}
}
- @Override
- protected void onAttach() {
- super.onAttach();
- if (initialContentReceived) {
- sizeInit();
- }
- }
-
@Override
protected void onDetach() {
rowRequestHandler.cancel();
*
* * Makes deferred request to get some cache rows
*/
- private void sizeInit() {
+ void sizeInit() {
+ if (!sizeNeedsInit) {
+ return;
+ }
+ sizeNeedsInit = false;
/*
* We will use browsers table rendering algorithm to find proper column
* widths. If content and header take less space than available, we will
}
+ @Override
+ public void setWidth(String width) {
+ String oldWidth = getElement().getStyle().getWidth();
+ if (!oldWidth.equals(width)) {
+ super.setWidth(width);
+ updateWidth();
+ }
+ }
+
void updateWidth() {
if (!isVisible()) {
/*
} else {
- // Readjust size of table
- sizeInit();
+ sizeNeedsInit = true;
// readjust undefined width columns
triggerLazyColumnAdjustment(false);