Display pets of an owner in Owner Browser screen

Hello

What are the options to display pets of an owner in Owners Browser screen? I want something like GroupTable but also want to display all columns of owner. It has to be usual owner screen along with pets.

Hi,
The easiest way to display pets would be to display them in a separate table in the same screen.
The layout can be like in the “master-detail” screen template.
The data container of the Pets table can be connected to the data container of the Owners table to refresh its data automatically.

If you want to display two kinds of entities (Pet and Owner) in the same table - you would need to use a KeyValueEntity or to create new non-persistent entity class (with links to Pet and Owner) for this purpose, because CUBA table needs a single entity class to be displayed and to determine available columns.

Can you please point to an example for first approach using two separate tables? I am trying to reuse same collection property from second level data container but unable to do that. My scenario is is analogous to Pet->Health Record->Attachments. Master screen is of Pets and I need to show attachments against Health record in detail tab. Can I reuse attachments property from heathRecordsDc?

You mean, you want to display attachments of a health record of the Pet, in the Pet editor?
It’s possible with a nested collection container.
For example:

 <data>
        <instance id="petDc"
                  class="com.company.pethealth.entity.Pet">
            <view extends="_local">
                <property name="healthRecords" view="_local">
                    <property name="pet" view="_minimal"/>
                    <property name="attachments" view="_local"/>
                </property>
            </view>
            <loader/>
            <collection id="healthRecordsDc" property="healthRecords">
                <collection id="attachmentsDc" property="attachments"/>
            </collection>
        </instance>
</data>
...
        <label value="Attachments of health record" stylename="h1"/>
        <table id="attachmentsTable" height="200px" width="400px" dataContainer="attachmentsDc">
            <columns>
                <column id="..."/>
            </columns>
        </table>

Thanks @albudarov, nested collections against nested properties is new for me :slightly_smiling_face: