The recommended approach is to check, when the page loads (page load microflow) or in the DataGrid2 datasource microflow, whether there is at least one non-empty value in the relevant column. For example, you can do a simple retrieve to check if there is any record where the INR field is not empty.
You then store the result of this check in a Boolean variable, for example HasINRValues. If at least one record has a value, this Boolean is set to true; otherwise, it is set to false.
Next, in the DataGrid2, set the Visibility of the INR column to Conditional and use this Boolean as the condition. When the Boolean is false, the column will not be shown at all. When it is true, the column will be displayed normally.
DataGrid2 does not do this automatically, because it does not dynamically hide columns based on the loaded data. That’s why this explicit check is required.
In short, creating a small control microflow on page load or in the datasource to set a Boolean, and using that Boolean for column visibility, is the cleanest and most controlled solution.
hi,
In Mendix, a DataGrid/DataGrid2 column cannot be hidden dynamically based on the data inside the column itself (for example, when all rows are empty). Column visibility is evaluated before the data is rendered.
Use a helper Boolean to control column visibility:
ShowMyColumn = true/falseIf the column is optional:
You cannot hide a column purely based on “all values are empty” without pre-processing the data in a microflow.
This is a platform limitation, not a configuration issue.
Hello,
I would like to add that if you are calculating a certain attribute in a Microflow that serves as input for a certain page, you will most certainly need to pass some kind of object to that page. Please correct me if I am wrong, but you cannot simply have a Boolean as a page parameter in Mendix.
Kind regards,
João