GWT - 可以将 FormPanel 嵌套在 FormPanel 中吗?
我正在尝试将 FormPanel 嵌套在另一个 FormPanel 中。似乎嵌套面板中的任何字段都不会被渲染。
此屏幕截图由其下面的代码生成:
TabItem tabItem = new TabItem("Tab Item");
FormPanel formPanel = new FormPanel();
formPanel.setHeading("Form Panel");
formPanel.setFrame(true);
TextField textField = new TextField();
textField.setFieldLabel("Text Field");
FormPanel nestedPanel = new FormPanel();
nestedPanel.setHeading("Nested Panel");
TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");
nestedPanel.add(nestedField);
TextField anotherField = new TextField();
anotherField.setFieldLabel("Another Field");
formPanel.add(textField);
formPanel.add(nestedPanel);
formPanel.add(anotherField);
tabItem.add(formPanel);
tabPanel.add(tabItem);
任何人都可以解释为什么嵌套字段没有显示在嵌套面板?
我还尝试使用 CaptionPanel 而不是 FormPanel 作为嵌套面板,但标题面板不显示字段标签。
任何有关我如何让它发挥作用的建议都将受到欢迎。谢谢 :)
I'm trying to nest a FormPanel inside another FormPanel. It seems that any field in the nested panel is never rendered.
This screenshot is produced by the code below it:
TabItem tabItem = new TabItem("Tab Item");
FormPanel formPanel = new FormPanel();
formPanel.setHeading("Form Panel");
formPanel.setFrame(true);
TextField textField = new TextField();
textField.setFieldLabel("Text Field");
FormPanel nestedPanel = new FormPanel();
nestedPanel.setHeading("Nested Panel");
TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");
nestedPanel.add(nestedField);
TextField anotherField = new TextField();
anotherField.setFieldLabel("Another Field");
formPanel.add(textField);
formPanel.add(nestedPanel);
formPanel.add(anotherField);
tabItem.add(formPanel);
tabPanel.add(tabItem);
Can anyone explain why the nested field does not show in the nested panel?
I've also tried using a CaptionPanel instead of a FormPanel as the nested panel, but the caption panel does not show the field label.
Any suggestions as to how I can get this to work would be most welcome. Thank you :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Jason 提到的,
要模拟
FormPanel
的外观,有两个基本步骤。ContentPanel
,并向其中添加内容FormLayout
。这看起来像这样(从您的示例来看)
外部字段仍然会管理任何绑定,并且嵌套字段看起来就像它们在 FormPanel 中一样。如果不使用 FormPanel 的其他功能,通常将 ContentPanel(或 LayoutContainer,如果您不需要边框/标题)与 FormLayout 一起使用可能更有意义。
As Jason mentioned,
<form>
cannot be nested. The GXTFormPanel
draws a form as part of how it works, so consider drawing this layout in another way.To emulate the appearance of the
FormPanel
, there are two basic steps.ContentPanel
, and add the content to thatFormLayout
in the content panel.This will look something like this (from your example)
The outer field will still manage any binding, and the nested field will look as if they were in a FormPanel. If not using other features of the FormPanel, it may in general make more sense to use a ContentPanel (or LayoutContainer, if you don't want the border/header) with a FormLayout.