sukharevd
2 Feb 2012, 3:14 AM
Hello,
I'm trying to implement dynamical change of LayoutContainers inside another LayoutContainer.
I want internal container to fit to all space of external container. I tried two following approaches
http://www.sencha.com/forum/showthread.php?78914-Add-Dynamically-Component-to-a-Container
http://stackoverflow.com/questions/3961379/dynamically-add-widget-to-gxt-sencha-widget (setLayoutOnChange),
but without luck.
The problem is that internal container is rendered, but its size is 100px x 100px. After resizing browser window, the size of internal container is 100% x 100% again (as I want), but I can't get this before resizing browser. UPD: Forgot to said that initially everything is good, but after the first remove/add (see code) the problem appears.
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;
public class MainContainer extends LayoutContainer {
public enum ViewType { TYPE1, TYPE2 }
private ViewType viewType;
private LayoutContainer contentContainer;
public ViewType getViewType() {
return viewType;
}
public void setViewType(ViewType viewType) {
this.viewType = viewType;
updateContantContainer(viewType);
}
private void updateContantContainer(ViewType viewType) {
if (contentContainer != null) {
remove(contentContainer);
}
if (viewType == null || viewType == ViewType.TYPE1) {
contentContainer = new TreeLayoutContainer();
} else {
contentContainer = new GridLayoutContainer();
}
add(contentContainer);
}
protected void onRender(Element target, int index) {
super.onRender(target, index);
setLayout(new FitLayout());
//setSize("100%", "100%");
setId("grcMainContainer");
setStyleAttribute("margin", "0px");
setLayoutOnChange(true);
updateContantContainer(viewType);
}
}
I check it in FF9, Chome 16, IE8.
Best regards, Dmitriy.
I'm trying to implement dynamical change of LayoutContainers inside another LayoutContainer.
I want internal container to fit to all space of external container. I tried two following approaches
http://www.sencha.com/forum/showthread.php?78914-Add-Dynamically-Component-to-a-Container
http://stackoverflow.com/questions/3961379/dynamically-add-widget-to-gxt-sencha-widget (setLayoutOnChange),
but without luck.
The problem is that internal container is rendered, but its size is 100px x 100px. After resizing browser window, the size of internal container is 100% x 100% again (as I want), but I can't get this before resizing browser. UPD: Forgot to said that initially everything is good, but after the first remove/add (see code) the problem appears.
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;
public class MainContainer extends LayoutContainer {
public enum ViewType { TYPE1, TYPE2 }
private ViewType viewType;
private LayoutContainer contentContainer;
public ViewType getViewType() {
return viewType;
}
public void setViewType(ViewType viewType) {
this.viewType = viewType;
updateContantContainer(viewType);
}
private void updateContantContainer(ViewType viewType) {
if (contentContainer != null) {
remove(contentContainer);
}
if (viewType == null || viewType == ViewType.TYPE1) {
contentContainer = new TreeLayoutContainer();
} else {
contentContainer = new GridLayoutContainer();
}
add(contentContainer);
}
protected void onRender(Element target, int index) {
super.onRender(target, index);
setLayout(new FitLayout());
//setSize("100%", "100%");
setId("grcMainContainer");
setStyleAttribute("margin", "0px");
setLayoutOnChange(true);
updateContantContainer(viewType);
}
}
I check it in FF9, Chome 16, IE8.
Best regards, Dmitriy.