PDA

View Full Version : Field width on collapsed Content Panel



VadimV1144
2 Aug 2010, 12:42 PM
Hi, I keep running into the auto width issues when something is initially rendered as hidden or collapsed.
To illustrate this issue I have constructed a simple example.

There are two identical ContentPanels with FormLayout and two fields. In the ContentPanel that is collapsed at render time, the fields are not fully expanded (I assume the autowidth value is used for the width) to the FormData specification (95% of the width of the parent container).

What do I have to set or call in order for the fields to behave properly regardless of the initial collapse/hide state of the parent component?




public void onModuleLoad() {

LayoutContainer lc = new LayoutContainer(new RowLayout(Style.Orientation.VERTICAL));
lc.setSize(800,800);
lc.setBorders(true);

lc.add(getFormLayout("Expanded", false), new RowData(-1,-1, new Margins(10,10,10,10)));
lc.add(getFormLayout("Collapsed", true), new RowData(-1,-1, new Margins(10,10,10,10)));

RootPanel.get().add(lc);
}

private ContentPanel getFormLayout(String heading, boolean collapsed){
ContentPanel cp = new ContentPanel(new FormLayout());
cp.setCollapsible(true);
cp.setHeading(heading);
if(collapsed)
cp.collapse();

TextField tf_one = new TextField();
tf_one.setFieldLabel("Field One");
tf_one.setName("fieldOne");
tf_one.setAutoWidth(true);
tf_one.setBorders(true);

TextField tf_two = new TextField();
tf_two.setFieldLabel("Field Two");
tf_two.setName("fieldTwo");
tf_two.setBorders(true);

cp.add(tf_one, new FormData("95%"));
cp.add(tf_two, new FormData("95%"));

return cp;
}


P.S.
Another interesting "feature" is when setAutoWidth is set to true ("Field One") and the FormData is at 95% , the Field's inputable text region takes up 95% as it supposed to, but the border for the given field takes up all 100% of the ContentPanel width.

sven
2 Aug 2010, 1:01 PM
Instead of using RowData(-1,-1) you need to use RowData(1,-1). You also probably need to use GXT 2.2 beta1