I have a Grid in which I want to enable / disable some Columns by the controller based on some database entries. The enabling/disabling happens in onInit().
I only see the ability to set the width to 0. But as there are 97 columns in the grid, it might lead to a loading issue if there are only 20 columns to display.
It’s not entirely clear what problem you’re having. You can control the visibility of the column using the io.jmix.flowui.component.grid.DataGridColumn#setVisible method.
My question is: I have 97 columns defined. But for some users I need only 20 columns. Does it make sense to load 97 columns and make 77 columns notVisible ?
Or should I define in the descriptor a grid and add the columns programmatically ?
If you define 97 columns and hide most of them, it will be:
A lot of code.
All 97 columns will be created using loaders from XML → processor time will be wasted.
All these objects will be stored in the heap and will not be used → memory will be wasted.
It seems to me that it would be more optimal to define an empty dataGrid and programmatically add columns to it. This way unnecessary columns will not be calculated and created, thus saving time and memory.
Columns must be added using the metaPropertyPath: io.jmix.flowui.component.grid.DataGrid#addColumn(java.lang.String, io.jmix.core.metamodel.model.MetaPropertyPath).