implementing dynamic way of datagrid

0
I need to display client and stage data in a datagrid where clients appear as rows and stages as columns. I have 3 client objects and 2 stage objects, with each client linked to all stages. For each client-stage combination, I need to assign a user.Context:I'm working with two entities: Client (3 objects) and Stages (2 objects). The requirement is to create a matrix-style layout in a datagrid.What I Need:Guidance on how to structure the datagrid so that each row represents a client, each column represents a stage, and I can assign users to each client-stage intersection.
asked
2 answers
0

Maybe this widget could help in defining a solution for your use case: https://marketplace.mendix.com/link/component/216495

answered
0

One practical way to handle this is to use a helper / view-model entity.


In this approach, you create a non-persistent entity that is only used for the page. This entity represents one row in the grid, so usually one client = one helper object.


For example, if you have 3 clients, you create 3 helper objects.

Each helper object can contain:

  • a reference or attribute for the Client
  • a field for each stage column, such as Stage1User, Stage2User, etc.


So instead of trying to make the datagrid generate columns dynamically from the Stage entity, you prepare the row structure yourself in advance.


The flow usually looks like this:

First, when opening the page, run a microflow to prepare the data.


In that microflow:

  • retrieve all Client objects
  • retrieve all Stage objects
  • for each client, create one non-persistent helper object
  • for each known stage, find the related assignment or existing value
  • fill the matching helper field, such as Stage1User or Stage2User


Then use the list of helper objects as the datasource of the datagrid.


So your datagrid is no longer directly showing Client or Stage data.

It is showing the prepared helper rows.


A simple example:

If you have:

  • Client A
  • Client B

and stages:

  • Stage 1
  • Stage 2

then your helper entity might look like this:

  • Row 1 → Client A, Stage1User = John, Stage2User = Emma
  • Row 2 → Client B, Stage1User = Mike, Stage2User = Lisa


In the UI:

  • one column shows the client name
  • one column shows Stage1User
  • one column shows Stage2User


This makes the datagrid easy to build because the columns are fixed.


This solution works best when the number of stages is known and limited.

For example, if you always have 2, 3, or 5 stages, this is manageable.


But if users can add or remove stages at runtime, this becomes difficult, because every new stage would require:

  • a new field in the helper entity
  • a new datagrid column
  • updated microflow logic


If you also need to save changes back to the database, then after the user edits the helper row values, you can run another microflow that:

  • reads the helper object values
  • finds or creates the real ClientStageAssignment records
  • saves the selected users for each client-stage combination


So in short, this option works by using the helper entity as a UI layer between the page and the real data model.


If this resolves your issue, please mark it as accepted.


answered