How to Hide Column in Datagrid2 based on the Condition

0
I need to Hide column When there is empty data in the Columns. Please find the screen shot for reference. Need to Hide 'INR' Column. Since its empty all the company details
asked
3 answers
0

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.


answered
0

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.

Recommended approach

Use a helper Boolean to control column visibility:

  1. Before loading the grid, run a microflow that:
    • Checks whether any record has a value for that attribute
    • Sets a Boolean like ShowMyColumn = true/false
  2. Use that Boolean in the column’s Visibility condition.

Alternative (simpler but less flexible)

If the column is optional:

  • Hide it by default
  • Show it only when a known condition is met (user input, filter, button click)

Important note

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.


answered
0

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

answered