如何在 Smartgwt 2.4 中将 TextItem 添加到 HLayout?
我想将 TextItem
组件添加到 SmartGwt 中的 HLayout
中。 我只是想避免将每个组件添加到DynamicForm
,然后添加到Layout
相反,我想直接将 TextItem
添加到 HLayout
中。
public class Test4 implements EntryPoint {
DynamicForm dynamicForm = new DynamicForm();
TextItem textItem = new TextItem();
HLayout hLayout = new HLayout();
public void onModuleLoad() {
// dynamicForm.setFields(textItem);
hLayout.addMember(textItem);
hLayout.draw();
}
}
I want to add a TextItem
component into a HLayout
in SmartGwt.
I would just want to avoid adding each component to DynamicForm
and then to a Layout
Instead I want to directly add a TextItem
to HLayout
.
public class Test4 implements EntryPoint {
DynamicForm dynamicForm = new DynamicForm();
TextItem textItem = new TextItem();
HLayout hLayout = new HLayout();
public void onModuleLoad() {
// dynamicForm.setFields(textItem);
hLayout.addMember(textItem);
hLayout.draw();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HLayout.addMember() 方法接受 Widget 或 Canvas 作为参数。 TextItem 扩展了 FormItem,但不扩展上述任何类。因此不可能实现您的代码所述的内容。您唯一的解决方案是使用 setFields() 方法通过 DynamicForm 添加它。如果您有多个 TextItem,您可以调用如下所示的内容:
如果您不希望能够更改 textItem 的值,您始终可以使用 Label 或从更简单的类创建自定义小部件以实现以下外观:文本项。
HLayout.addMember() method accepts a Widget or Canvas as an argument. TextItem extends the FormItem which doesn't extent any of the above classes. Thus it is imposible to achieve what your code states. Your only solution is to add it through a DynamicForm using the setFields() method. If you have more than one TextItems you can just call something like the below:
If you do not wish to be able to change the value of the textItem you can always use a Label or create a custom widget from simpler classes to achieve the look of the TextItem.