gridColumnVisibility how to persist column visibility settings?

Hi,

i am using:

<gridColumnVisibility dataGrid="propertiesDataGrid"
                                              icon="COG"
                                              themeNames="icon"/>

i have also implemented facet
<settings auto="true"/>

but i believe that facet is only saving sorting of table not visiblity. How to also save visibility of columns in datagrid?

Hello Igor!

What Jmix version are you using? I tested version 2.4.2, and the column visibility is also saved. Additionally, you can check it using the Entity Inspector and search for “User settings (flowui_UserSettingsItem).” The row for your view will contain the saved JSON.

Okay updated to latest version and now i at least get warning: DataGrid contains one or more columns without key specified, settings for them will not be stored

So it seems that when table has some generated collumns it is not possible to automatically save adding columns?

Sorting of table is still saved …

You should specify the “key” of the column. For instance, if column is added programmatically:

@Subscribe
public void onInit(final InitEvent event) {
    myDataGrid.addColumn(new TextRenderer<>(item -> "Custom column value: " + item.getCustomValue()))
            .setHeader("Custom column")
            .setKey("customColumn");
}

Or if you have column definition in XML:

<column key="declarativeColumn" header="Declarative column"/>