Dynamic columns for the datagrid 2 widget - Mendix Forum

Dynamic columns for the datagrid 2 widget


It would be great to allow the developer to dynamically generate the amount of columns at runtime in the datagrid2 widget.

In our use-case, we create a dashboard table entry and associate a one to many table to it, to configure the columns. This would allow us, and many others, to create generic pages that can be configurable in the app for the needs of the people.

First dashboard:
A dashboard entry called “Production” can be made. Associated to it are 5 column entries, named P1 through P5.
Second dashboard:
A dashboard entry called “Logistics” can be made. Associate to it are 3 column entries named L1 through L3.

Now people from the production floor and people from logistics can use the same page layout with a data grid that allows for a dynamic number of columns because of their different needs and the developer only has to make 1 page instead of X pages, each tailored to the needs of each department.

4 answers

Thanks @Andries Smit. Works exactly as I need it! 


I Published a widget that can probably help you out

Data Grid with variable columns. No more list view in list views!


  • Data Grid, with variable number of columns.
  • Render cell content: attribute, text or user custom to build your onw cell content, including editable inputs.
  • Empty row content message.
  • Empty cell objects can be omitted when "Optimize cell paging" is disabled.
  • On click action on row, column and or cells
  • Choose the default styling of the Data Widget Grid 2 widget, or render it as a plain HTML table without any styling.
  • Options for pagination for Row, Column or non.
  • Structure mode preview in the Studio Pro.

Upvoted… but…
If this is option is implemented or not, it would be great if the columns can be given a unique, “technical” name.

The personalization configuration is now saved using the Caption and is thus depending on the user's language.

I already have logic in place to hide or display columns but had to do it for each possible language.

Changing the caption means that also the MF logic must be changed (whic is often forgotten).

But changing the caption also means that users loose their personalization.


Hi Arne,


There is a Matrix widget that lets you dynamically set columns you might want to look into: