我正在创建 ContentPanel 并将其隐藏:
final ContentPanel infoPanel = new ContentPanel();
final TabPanel infoTabPanel = new TabPanel();
...
//Adding TabItems with some forms
infoPanel.add(infoTabPanel);
infoPanel.hide();
add(infoPanel);
然后在一些事件监听器中,我尝试显示这个隐藏的面板:
infoPanel.show();
infoPanel.layout();
但是这个面板没有任何数据显示。只有当我点击标签数据时才会出现。
那么如何正确隐藏/显示这个面板呢?
编辑:
我正在使用 GXT 2.2.4。
我正在使用包含 FormPanel 并隐藏 ContentPanel 的 TabPanel 创建 ContentPanel。
然后在事件侦听器中,我尝试显示这个隐藏的面板,但它没有表单显示。只有当我点击标签表单时才会出现。
这是代码:
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);
final ContentPanel infoPanel = new ContentPanel();
infoPanel.setAutoHeight(true);
final TabPanel infoTabPanel = new TabPanel();
infoTabPanel.setAutoHeight(true);
final FormPanel testForm = new FormPanel();
FieldSet fieldSet = new FieldSet();
fieldSet.setHeading("Information");
FormLayout fLayout = new FormLayout();
fieldSet.setLayout(fLayout);
LabelField field1 = new LabelField();
LabelField field2 = new LabelField();
field1.setFieldLabel("Field1:");
field1.setName("field1");
fieldSet.add(field1);
field2.setFieldLabel("Field2:");
field2.setName("field2");
fieldSet.add(field2);
testForm.add(fieldSet);
TabItem formTab = new TabItem("Form Tab");
formTab.add(testForm);
infoTabPanel.add(formTab);
TabItem longText = new TabItem("Long Text");
longText.addStyleName("pad-text");
longText.addText("Long Text" + "<br>" + "Long TextLong Text");
infoTabPanel.add(longText);
infoPanel.add(infoTabPanel);
infoPanel.hide();
Button buttonShow = new Button("show");
buttonShow.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
infoPanel.show();
}
});
Button buttonHide = new Button("hide");
buttonHide.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
infoPanel.hide();
}
});
add(infoPanel);
add(buttonShow);
add(buttonHide);
}