我有一个屏幕,其表格处理与实体(简单,2个字段)的多对多关系,其中还定义了1个单个记录.
我为关联实体创建了标准浏览器屏幕,并为前一个屏幕的操作表“添加”定义了openType = DIALOG.
然后对话窗口的高度压得太紧(见下面的截图),我想这是因为没有足够的实体来显示高度计算是错误的.
如果我在对话框窗口中进行“分析布局”,我会收到以下警告:
[WARN] Nested component 'contactEmailsTable'
Nested component has relative height 100.0% inside window with undefined height
作为一种解决方法,我试图在工作室中手动设置表高度,没有机会.
没有在工作室中看到手动窗口高度的设置,所以我试图通过覆盖init方法重新定义它(见下文),没有机会.
@Override
public void init(Map<String, Object> params) {
super.init(params);
int unit = getHeightUnits();
float height = getHeight();
switch(unit) {
case UNITS_PIXELS:
setHeight(""+height * 1.10f+"px");
case UNITS_PERCENTAGE:
setHeight(""+Math.min(100, height + 0.10f)+"%");
}
}
下面是所述对话框的xml.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://browseCaption"
class="com.busy.busyapp.gui.contactemail.ContactEmailBrowse"
focusComponent="contactEmailsTable"
lookupComponent="contactEmailsTable"
messagesPack="com.busy.busyapp.gui.contactemail">
<dsContext>
<collectionDatasource id="contactEmailsDs"
class="com.busy.busyapp.entity.ContactEmail"
view="_local">
<query>
<![CDATA[select e from busyapp$ContactEmail e]]>
</query>
</collectionDatasource>
</dsContext>
<layout expand="contactEmailsTable"
spacing="true">
<filter id="filter"
applyTo="contactEmailsTable"
datasource="contactEmailsDs">
<properties include=".*"/>
</filter>
<table id="contactEmailsTable"
presentations="true"
width="100%">
<actions>
<action id="create"/>
<action id="edit"/>
<action id="remove"/>
<action id="excel"/>
</actions>
<columns>
<column id="label"/>
<column id="email"/>
</columns>
<rows datasource="contactEmailsDs"/>
<rowsCount/>
<buttonsPanel id="buttonsPanel"
alwaysVisible="true">
<button id="createBtn"
action="contactEmailsTable.create"/>
<button id="editBtn"
action="contactEmailsTable.edit"/>
<button id="removeBtn"
action="contactEmailsTable.remove"/>
<button id="excelBtn"
action="contactEmailsTable.excel"/>
</buttonsPanel>
</table>
</layout>
最佳答案 以下示例显示如何管理对话框窗口尺寸.
将屏幕打开为具有已定义宽度和高度的对话框:
openEditor(entity, OpenType.DIALOG.width(480).height(320));
在其控制器中设置屏幕的宽度和高度:
@Override
public void init(Map<String, Object> params) {
getDialogOptions().setWidth(480).setHeight(320);
}
XML描述符中相同:
<dsContext/>
<dialogMode width="480" height="320"/>
<layout/>
指定屏幕应始终作为对话框打开:
@Override
public void init(Map<String, Object> params) {
getDialogOptions().setForceDialog(true);
}
XML描述符中相同:
<dsContext/>
<dialogMode forceDialog="true"/>
<layout/>