GWT - 可以将 FormPanel 嵌套在 FormPanel 中吗?

发布于 2025-01-03 04:03:47 字数 957 浏览 0 评论 0原文

我正在尝试将 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:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-01-10 04:03:47

正如 Jason 提到的,

不能嵌套。 GXT FormPanel 绘制表单作为其工作方式的一部分,因此请考虑以其他方式绘制此布局。

要模拟 FormPanel 的外观,有两个基本步骤。

  • 要获取标题、边框,请创建一个 ContentPanel,并向其中添加内容
  • 要获取绘制字段标签的 GXT 2 布局,请在内容面板中使用 FormLayout

这看起来像这样(从您的示例来看)

//...
ContentPanel nestedPanel = new ContentPanel(new FormLayout();
nestedPanel.setHeading("Nested Panel");

TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");

nestedPanel.add(nestedField);
//...

外部字段仍然会管理任何绑定,并且嵌套字段看起来就像它们在 FormPanel 中一样。如果不使用 FormPanel 的其他功能,通常将 ContentPanel(或 LayoutContainer,如果您不需要边框/标题)与 FormLayout 一起使用可能更有意义。

As Jason mentioned, <form> cannot be nested. The GXT FormPanel 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.

  • To get the header, border, create a ContentPanel, and add the content to that
  • To get the GXT 2 layout of drawing the field labels, use a FormLayout in the content panel.

This will look something like this (from your example)

//...
ContentPanel nestedPanel = new ContentPanel(new FormLayout();
nestedPanel.setHeading("Nested Panel");

TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");

nestedPanel.add(nestedField);
//...

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文