Does having identical datagrid column ids affect the installation of column editors, generators?

Hi again,

I have a screen where I create two datagrids pointing to different dataContainers but for the same entity class.

I am setting the ids of the columns for both datagrids to the properties of the entity that needs to be edited. But the editor is only being installed in the first table not the second.

I am wondering if the fact that I have columns with identical ids from different datagrids (datagrids named differently of course) poses a problem when @installing editfieldgenerators and column generators.

Any thoughts are greatly appreciated.
Regards,
Carlos.

Hi.

We strongly recommend not to set identical ids for different elements in the same XML. It may cause some problems during work.

We have already added several inspections for checking uniqueness (see issue) and will continue to add them in the future.

Regards,
Natalia

Could you please clarify the exact problem you faced?

Hi Natalia,
thanks for your attention.

Find attached the controller and descriptor of the user case I am trying to solve. This is part of an essay in developing the logic of an accounting application. It’s in spanish. But language will not play any role in our discussion.

AsientoEdit.java (4.9 KB)
and the descriptor code:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window"
        caption="msg://asientoEdit.caption"
        focusComponent="form">
    <data>
        <instance id="asientoDc"
                  class="contabilidad.entity.Asiento">
            <fetchPlan extends="_base">
                <property name="ejercicio" fetchPlan="_base"/>
                <property name="movtosIva" fetchPlan="_base"/>
                <property name="movtosIrpf" fetchPlan="_base">
                    <property name="asiento" fetchPlan="_base"/>
                </property>
                <property name="apuntes" fetchPlan="_base">
                    <property name="cuentaContable" fetchPlan="_base"/>
                    <property name="asiento" fetchPlan="_base"/>
                </property>
            </fetchPlan>
            <loader/>
        </instance>
        <collection id="apuntesDebeDc" class="contabilidad.entity.Apunte">
            <fetchPlan extends="_base"/>
            <loader id="apuntesDebeDl">
                <query>
                    <![CDATA[select e from contabi_Apunte e]]>
                </query>
            </loader>
        </collection>
        <collection id="apuntesHaberDc" class="contabilidad.entity.Apunte">
            <fetchPlan extends="_base"/>
            <loader id="apuntesHaberDl">
                <query>
                    <![CDATA[select e from contabi_Apunte e]]>
                </query>
            </loader>
        </collection>
        <collection id="movtoIvasDc" class="contabilidad.entity.MovtoIva">
            <fetchPlan extends="_base"/>
            <loader id="movtoIvasDl">
                <query>
                    <![CDATA[select e from contabi_MovtoIva e]]>
                </query>
            </loader>
        </collection>
        <collection id="movtoIrpfsDc" class="contabilidad.entity.MovtoIrpf">
            <fetchPlan extends="_base"/>
            <loader id="movtoIrpfsDl">
                <query>
                    <![CDATA[select e from contabi_MovtoIrpf e]]>
                </query>
            </loader>
        </collection>
    </data>
    <facets>
        <dataLoadCoordinator auto="true"/>
        <screenSettings id="settingsFacet" auto="true"/>
    </facets>
    <actions>
        <action id="windowCommitAndClose" caption="msg:///actions.Ok"
                icon="EDITOR_OK"
                primary="true"
                shortcut="${COMMIT_SHORTCUT}"/>
        <action id="windowClose"
                caption="msg:///actions.Close"
                icon="EDITOR_CANCEL"/>
    </actions>
    <dialogMode height="600"
                width="800"/>
    <layout spacing="true" expand="scrollBox" width="100%">
        <scrollBox id="scrollBox" spacing="true" width="100%">
            <form id="form" dataContainer="asientoDc" width="100%">
                <column width="100%">
                    <entityPicker enable="false" id="ejercicioField" property="ejercicio">
                        <actions>
                            <action id="entityLookup" type="entity_lookup"/>
                            <action id="entityClear" type="entity_clear"/>
                        </actions>
                    </entityPicker>
                    <textField id="numAsientoField" property="numAsiento"/>
                    <dateField id="fechaField" property="fecha"/>
                    <textArea width="100%" id="descripcionField" property="descripcion"/>
                    <label value="Apuntes"/>
                    <hbox spacing="true" width="100%">
                        <dataGrid  editorBuffered="false" id="apuntesTableDebe" height="300px" width="100%" dataContainer="apuntesDebeDc">
                            <columns>
                                <column id="importe" property="importe" expandRatio="30"/>
                                <column id="cuentaContable" property="cuentaContable"  expandRatio="70">
                                    <htmlRenderer nullRepresentation="null"/>
                                </column>

                            </columns>
                        </dataGrid>
                        <dataGrid editorBuffered="false" id="apuntesTableHaber" height="300px" width="100%" dataContainer="apuntesHaberDc">
                            <columns>
                                <column  id="cuentaContable" property="cuentaContable" expandRatio="70">

                                    <htmlRenderer nullRepresentation="null"/>
                                </column>
                                <column id="importe" property="importe" expandRatio="30"/>
                            </columns>
                        </dataGrid>
                    </hbox>

                    <label value="Movimientos de IVA"/>

                    <table id="movtoIvasTable" height="100px" width="100%" dataContainer="movtoIvasDc">
                        <columns>
                            <column id="nif"/>
                            <column id="nombre"/>
                            <column id="fecha"/>
                            <column id="numFra"/>
                            <column id="importeBase"/>
                            <column id="tipoPorcentaje"/>
                            <column id="cuota"/>
                        </columns>
                    </table>
                    <label value="Movimientos de IRPF"/>
                    <table id="movtoIrpfsTable" height="100px" width="100%" dataContainer="movtoIrpfsDc">
                        <columns>
                            <column id="nif"/>
                            <column id="nombre"/>
                            <column id="fecha"/>
                            <column id="numFra"/>
                            <column id="base"/>
                            <column id="tipoPorcentaje"/>
                            <column id="cuota"/>
                        </columns>
                    </table>

                </column>
            </form>
        </scrollBox>
        <hbox id="editActions" spacing="true">
            <button id="commitAndCloseBtn" action="windowCommitAndClose"/>
            <button id="closeBtn" action="windowClose"/>
        </hbox>
    </layout>
</window>

So basically I display two tables that hold records of the same entity type. They consist of two columns, one of them has a basic numeric text editor, but the other one a combobox where I choose another entity type instance, that is a related entity to the one being edited in the table. I need to set a column generator and editor for that column, but since I have these two tables I am having issued displaying the editor and renderer for both tables. I have reached it getting to work properly if eliminating one of the two tables.

a possible solution would be to create different entity versions corresponding to each of the table. But that’s not very concordant with the data model and efficiency in data model design.

Any solutions? If you wish I can upload the project.

Regards,
Carlos.

I managed to solve it, but dont know exactly how… all of a sudden the code works.
Sorry for not giving anyother info, only that the above code seems to be correct. Can’t explain why it was not working before.

Regards,
Carlos.

1 Like

Hi Natalia,

I don’t know if you may following this post anymore, since I marked it solved a while ago.

I am having again the same issues… sometimes it works, sometimes it doesn’t. I have packaged the project in a zip file and uploaded it for anyone that may be able to help to examine it.

So the point is that in the AsientoEdit screen I have two datagrids where the editors consisting of dropdown lists will render at certain occasions, and other don’t. And can’t explain what originates this behavior.

I presume the most likely problem is having identical id’s for the columns in the datagrid. But that’s necessary to be like that, since the entity Apunte is associated with Asiento via two members: apuntesDebe and apuntesHaber.

Contabilidad.zip (106.6 KB)

It’s an accounting application so that’s why.

Any ideas are greatly welcome.

Thanks and regards,
Carlos.

Hi.

Thank you for reporting the problem. We have created a GitHub issue.

As a workaround, I suggest setting up both generated columns and edit generators in the InitEvent method.

Done. Thanks for the hint.

Regards,
Carlos.

1 Like