尝试从包含按钮的网格呈现程序中打开一个对话框。问题是对话框不尊重指定的大小。
我尝试过设置对话框的宽度和高度,但是它不会影响DOM元素,只会影响它的子元素(看起来不像预期的那样)。
@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);
}发布于 2019-05-03 14:41:04
通过使用Lumo主题而不是材料主题来解决这个问题。
发布于 2019-07-28 13:04:52
最近也面临同样的情况。可以通过使用@HtmlImport对对话框进行样式设置来禁用宽度限制:
@HtmlImport("styles/order-edit.html")
class OrderEdit(val orderId: String, okHandler: (Order)->Unit): Dialog() {
...
}内容如下:
<dom-module id="dialog-fix" theme-for="vaadin-dialog-overlay">
<template>
<style>
[part~="overlay"]{
max-width: none !important;
}
</style>
</template>
</dom-module>https://stackoverflow.com/questions/55631881
复制相似问题