villemustonen
16 Oct 2008, 2:12 AM
Hello,
The Explorer had an example where a fields FormData could be set to "100%" and it would auto-size itself with the container, if the container has FitLayout.
My problem is that in my application the main window has a BorderLayout, and there is a ContentPanel with several FormPanels inside whose fields I would like to resize when the east panel is resized. This works in Firefox, but not in IE. (To be fair, it doesn't completely work in Firefox either)
In IE, the auto-resizing works for the first FormPanels fields, but not the others. So if I increase the east panels size, the fields sizes increase, but when I decrease it, only the first FormPanel resizes its fields, not the others. In Firefox, it works almost as it should, except when decreasing the fields size, all other FormPanels except the first have a slightly different field width.
Runnable test code:
package com.test.client;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
public class TestModule extends Window {
private ContentPanel north;
private BorderLayoutData northData;
private ContentPanel west;
private BorderLayoutData westData;
private ContentPanel east;
private BorderLayoutData eastData;
private ContentPanel center;
private BorderLayoutData centerData;
private ContentPanel eastContents;
public void onModuleLoad() {
setLayout(new BorderLayout());
initPanels();
eastContents = initEastContents();
east.add(eastContents);
add(north, northData);
add(west, westData);
add(east, eastData);
add(center, centerData);
setWidth(1024);
setHeight(768);
show();
}
/**
* Create a ContentPanel with FitLayout that has two FormPanels, each with
* 10 fields, inside.
*
* @return ContentPanel
*/
private ContentPanel initEastContents() {
ContentPanel cp = new ContentPanel();
cp.setScrollMode(Scroll.AUTO);
cp.setLayout(new FitLayout());
cp.setHeaderVisible(false);
for (int n = 0; n < 2; n++) {
FormPanel panel = new FormPanel();
panel.setAutoHeight(true);
for (int i = 0; i < 10; i++) {
TextField<String> field = new TextField<String>();
field.setFieldLabel("Field" + i);
panel.add(field, new FormData("100%"));
}
cp.add(panel);
}
return cp;
}
/**
* Initializes the BorderLayout-panels,
* EastPanel has FitLayout
*/
private void initPanels() {
// North-panel
north = new ContentPanel();
north.setCollapsible(true);
north.setHeading("North");
north.setHeaderVisible(true);
northData = new BorderLayoutData(LayoutRegion.NORTH, 80, 80, 80);
northData.setCollapsible(true);
northData.setFloatable(false);
northData.setSplit(true);
northData.setMargins(new Margins(3, 3, 0, 3));
// West-panel
west = new ContentPanel();
west.setHeading("West");
west.setHeaderVisible(true);
west.setScrollMode(Scroll.AUTO);
westData = new BorderLayoutData(LayoutRegion.WEST, 150);
westData.setSplit(true);
westData.setCollapsible(true);
westData.setFloatable(true);
westData.setMargins(new Margins(3));
// East-panel
east = new ContentPanel();
east.setLayout(new FitLayout());
east.setHeading("East");
east.setHeaderVisible(true);
east.setCollapsible(true);
eastData = new BorderLayoutData(LayoutRegion.EAST);
eastData.setSplit(true);
eastData.setCollapsible(true);
eastData.setFloatable(true);
eastData.setMargins(new Margins(3));
// Center-panel
center = new ContentPanel();
center.setLayout(new FitLayout());
center.setHeading("South");
center.setHeaderVisible(true);
center.setBodyBorder(false);
centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(3, 0, 3, 0));
centerData.setCollapsible(false);
centerData.setFloatable(false);
}
}
The Explorer had an example where a fields FormData could be set to "100%" and it would auto-size itself with the container, if the container has FitLayout.
My problem is that in my application the main window has a BorderLayout, and there is a ContentPanel with several FormPanels inside whose fields I would like to resize when the east panel is resized. This works in Firefox, but not in IE. (To be fair, it doesn't completely work in Firefox either)
In IE, the auto-resizing works for the first FormPanels fields, but not the others. So if I increase the east panels size, the fields sizes increase, but when I decrease it, only the first FormPanel resizes its fields, not the others. In Firefox, it works almost as it should, except when decreasing the fields size, all other FormPanels except the first have a slightly different field width.
Runnable test code:
package com.test.client;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
public class TestModule extends Window {
private ContentPanel north;
private BorderLayoutData northData;
private ContentPanel west;
private BorderLayoutData westData;
private ContentPanel east;
private BorderLayoutData eastData;
private ContentPanel center;
private BorderLayoutData centerData;
private ContentPanel eastContents;
public void onModuleLoad() {
setLayout(new BorderLayout());
initPanels();
eastContents = initEastContents();
east.add(eastContents);
add(north, northData);
add(west, westData);
add(east, eastData);
add(center, centerData);
setWidth(1024);
setHeight(768);
show();
}
/**
* Create a ContentPanel with FitLayout that has two FormPanels, each with
* 10 fields, inside.
*
* @return ContentPanel
*/
private ContentPanel initEastContents() {
ContentPanel cp = new ContentPanel();
cp.setScrollMode(Scroll.AUTO);
cp.setLayout(new FitLayout());
cp.setHeaderVisible(false);
for (int n = 0; n < 2; n++) {
FormPanel panel = new FormPanel();
panel.setAutoHeight(true);
for (int i = 0; i < 10; i++) {
TextField<String> field = new TextField<String>();
field.setFieldLabel("Field" + i);
panel.add(field, new FormData("100%"));
}
cp.add(panel);
}
return cp;
}
/**
* Initializes the BorderLayout-panels,
* EastPanel has FitLayout
*/
private void initPanels() {
// North-panel
north = new ContentPanel();
north.setCollapsible(true);
north.setHeading("North");
north.setHeaderVisible(true);
northData = new BorderLayoutData(LayoutRegion.NORTH, 80, 80, 80);
northData.setCollapsible(true);
northData.setFloatable(false);
northData.setSplit(true);
northData.setMargins(new Margins(3, 3, 0, 3));
// West-panel
west = new ContentPanel();
west.setHeading("West");
west.setHeaderVisible(true);
west.setScrollMode(Scroll.AUTO);
westData = new BorderLayoutData(LayoutRegion.WEST, 150);
westData.setSplit(true);
westData.setCollapsible(true);
westData.setFloatable(true);
westData.setMargins(new Margins(3));
// East-panel
east = new ContentPanel();
east.setLayout(new FitLayout());
east.setHeading("East");
east.setHeaderVisible(true);
east.setCollapsible(true);
eastData = new BorderLayoutData(LayoutRegion.EAST);
eastData.setSplit(true);
eastData.setCollapsible(true);
eastData.setFloatable(true);
eastData.setMargins(new Margins(3));
// Center-panel
center = new ContentPanel();
center.setLayout(new FitLayout());
center.setHeading("South");
center.setHeaderVisible(true);
center.setBodyBorder(false);
centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(3, 0, 3, 0));
centerData.setCollapsible(false);
centerData.setFloatable(false);
}
}