You cannot bind two different entities directly to a Data Grid 2 in Mendix. A Data Grid 2 always works with one datasource entity, meaning each row in the grid represents one object of that entity.
If you need to display data coming from two entities, there are a couple of common approaches.
1. Use associations (recommended approach)
If the entities are related, you can use one entity as the grid datasource and display attributes from the associated entity in the columns.
For example, if you have Customer and Order entities, you can set Order as the datasource of the Data Grid 2. Then inside the grid columns you can display attributes such as:
In this case the grid still uses Order as the main entity, but it can display information from Customer through the association.
2. Create a helper (DTO) entity
If the entities are not directly related or you need to combine values into one row, you can create a helper entity (often non-persistent). Then use a microflow datasource to retrieve data from both entities and populate the helper entity with the required fields. Finally, bind the Data Grid 2 to this helper entity.
So in short, Data Grid 2 cannot have two root entities as its datasource. The recommended solution is to either:
If this resolves your issue, please mark the answer as accepted so it can help others in the community as well.
Hi Parag,
DataGrid 2 always needs one root data source entity. The strategy is to either bridge two entities through an association or NPE, so that DataGrid 2 sees a single unified structure while the data underneath comes from two entities.