Multiple rows in table per entity

I have entities that have a start date and an end date.

I would like a reporting table to show these entities in multiple rows - one per day - if they span more than one day.

This is for a report export to Excel.

Has anyone attempted to do this before?

You can use apache-poi to create excel files by yourself. Create an excel file and run through entities and add rows and cells to excel file (i.e. one per day from date range)

I would suggest defining a non-persistent entity that represents a row in the table.
image

Then in the screen:

  • Define a collection datasource for the non-persistent entity and set its attributes as follows:
    image

  • In the ready() method, load your data using DataManager and create appropriate instances of non-persistent entity using Metadata.create()

  • Add non-persistent entity instances to the datasource using its includeItem() method.

The table will show them and you will be able to export to Excel.

1 Like

Hi,

Would the above solution also apply the filters to the data or would I need to do that in my DataManager call?

Filter won’t work with the datasource containing non-persistent entities, because it just modifies the JPQL query of the datasource. However, you can define additional datasource for your original persistent entity and load data with it. This datasource would not be linked to any table, only to the filter. So instead of loading by DataManager, you will load by the filtered datasource.