A Repeater with Heterogeneous Information

Prev Next
This content is currently unavailable in French (Canada). You are viewing the default (English) version.

Introduction

  • For this example, use the repeater of the product Aggregate, built using a grid. To learn how to build it, refer to the “Use Grid to Create a Table” How To. Its columns will represent various fields of heterogeneous information common to any product type.

    From the Product Aggregate, create subtypes such as clothing and electronics. These represent categories of products. To see how, refer to step 1 of this document, where a Food subtype will be added. Fields that are unique to a subtype will be added under the subtype field section.

    The heterogeneous fields for the different product types could be brand, model, manufacturer, illustration and quantity. Those fields should be added immediately under the main Product Aggregate, as they are fields that any subtypes will share.

Step-by-step instructions

1. Creating Product Subtypes for Different Categories

To add a new subtype, right-click on the main Aggregate and select “create subtype”. In this example, do so using the Product one.

2. Adding Fields for Subtypes in the Product Aggregate

Add the following fields under the new subtype:

expirationDate

ingredients

3. Creating Subtype-Specific Commands

Each subtype needs its own creation command. Let’s add one for Food and select subtype-specific and heterogenous fields as its params.

4. Linking the commands to the UI

Add a toolbar button to the UI and link it to the food’s create command. When you add the Execute Command behaviour, notice that once Food has been selected as “typename”, the corresponding commands will be offered in the command name dropdown list.

Next, add a new Food product:

5. Creating a Calculated Field to Display Product Type

Finally, create a calculated field under product, for productType. In the Code section, add:

data.$type.name.toUpperCase()

This will add “product” as product type to the ones without any specific subtypes and will display a subtype when one was picked when the product was added.

Here is how this field would look once in our grid:

Conclusion

Implementing a repeater with heterogeneous information allows for better management and display of different product categories. By setting up subtypes and unique fields, users can ensure the correct data is captured and displayed dynamically.