How to correctly specify dialog size in vaadin-flow(如何在 vaadin-flow 中正确指定对话框大小)
问题描述
试图从包含按钮的网格渲染器中打开一个对话框.问题是对话框不遵守指定的大小.
Trying to open a dialog from a grid renderer which contain a button. The problem is that the dialog isn't respecting the specified size.
我尝试设置对话框的宽度和高度,但它不会影响 DOM 元素,只会影响它的子元素(看起来不像预期的那样)
I've tried setting the width and height of the dialog but it doesn't affect the DOM element only its childs (which doesn't look as expected)
@Override
public VerticalLayout createComponent(P item) {
// this simply create a VerticalLayout
VerticalLayout layout = super.createComponent(item);
HorizontalLayout subLayout = new HorizontalLayout();
subLayout.setWidthFull();
subLayout.setDefaultVerticalComponentAlignment(Alignment.CENTER);
this.button = new MSButton(this.colorClass, this.vaadinIcon);
this.button.addClickListener(event -> {
this.parent = item;
this.grid.getDataProvider().refreshAll();
this.dialog.open();
});
subLayout.add(this.button);
layout.add(subLayout);
return layout;
}
private void constructDialog() {
this.dialog = new Dialog();
H1 titleHolder = new H1(this.getDialogTitle());
titleHolder.addClassName("mt-0");
titleHolder.setWidthFull();
H3 headerHolder = new H3(this.getDialogHeaderText());
headerHolder.addClassName("mt-0");
headerHolder.setWidthFull();
HorizontalLayout headerRow = new HorizontalLayout();
headerRow.add(headerHolder);
headerRow.add(this.getDialogHeaderIcon().create());
headerRow.setWidthFull();
MSButton closeButton = new MSButton("Fermer", "success",
VaadinIcon.CHECK_CIRCLE_O, event -> {
dialog.close();
});
HorizontalLayout footerRow = new HorizontalLayout();
footerRow.add(closeButton);
VerticalLayout footer = new VerticalLayout();
footer.setDefaultHorizontalComponentAlignment(Alignment.END);
footer.setAlignItems(Alignment.END);
footer.setWidthFull();
footer.add(footerRow);
VerticalLayout container = new VerticalLayout();
container.add(titleHolder);
container.add(headerHolder);
container.add(this.grid);
container.add(footer);
this.dialog.setWidth("700px");
this.dialog.setHeight("500px");
this.dialog.add(container);
}
结果如下:https://ibb.co/HNcgLK2
推荐答案
修复了使用 Lumo 主题而不是 Material one 的问题.
Fixed the problem by using Lumo theme instead of Material one.
这篇关于如何在 vaadin-flow 中正确指定对话框大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 vaadin-flow 中正确指定对话框大小
基础教程推荐
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01