You need to download a grid widget from Marketplace that supports dynamic columns. The old Tree Table widget still works in Mendix 10.12.11. It can retrieve the column structure from a helper microflow. In fact, we never had time to try the similar modern widgets on Marketplace, but I'm sure there are some. See these:
Here's the screenshot from our app page designer