CUBA platform: invalid window height for the editor, opened as a dialog from a table action

I have a screen with a table processing the many-to-many relationship to the entity (simple, 2 fields), for which there is one more specific record.

I created a standard browser screen for the linked object and defined openType = DIALOG for the “add” action table of the previous screen.

Then the dialog box is too tightly packed in height (see screenshot below), I believe this is due to the fact that it is not enough to display objects so that the height calculation is incorrect.

dialog height incorrect

If I do a “layout analysis” in the dialog box, I get the following warning:

[WARN] Nested component 'contactEmailsTable'
Nested component has relative height 100.0% inside window with undefined height

As a workaround, I tried to manually set the table height in the studio, no chance.

, , , 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>

+4
1

, .

:

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/>
+2

Source: https://habr.com/ru/post/1651562/


All Articles