Retaining Column Selection in Data Grid2

0
Hi All,Currently we have a column selector option in DataGrid2. But the changes will be gone once we refresh the page or relogin.Is there a way to retain the selected columns per user basis.Like if I select some columns now and later relaunch the same page I could see same set of columns that I have selected but for others it should show all the columns.Do we have any inbuilt option for the same.?We are using 9.24.29RegardsAjay
asked
3 answers
1

In my marketplace module Convent Commons there is a section called 'User memory". Have a look, maybe it answers your question. The module is build for version 10 and higher, but you can easyly (re)build the "User memory" part for version 9.

answered
0

hi,



Yes Mendix DataGrid2 supports persisting column selections per user, but it only does so if you configure personalization properly. The grid itself does not automatically remember selections unless you explicitly set it up.

Built-in Mendix support (what it actually does)

DataGrid2 has personalization support which can save:

  • column visibility
  • column order
  • column width
  • This is stored as configuration in a String attribute so it can be reused later.

How to retain the columns per user (official way)

  1. Create a helper entity (e.g., UserGridConfig) with:
    • a 1-to-1 association to Account
    • an Unlimited String attribute (to store the config)
  2. On your page, wrap the DataGrid2 in a Data View bound to this config object.
  3. In DataGrid2 → Personalization tab:
    • Set Attribute to your unlimited String attribute
    • Set On change to “Save Changes” and commit the config object
  4. In a microflow (before the page opens), retrieve the current user’s config or create it if missing.

Now each user will have their own saved grid configuration — refresh and relogin will keep the same columns.

Why it’s per user

Since the config is stored in a user-linked entity attribute, each user will have their own saved personalization settings. Only that user will see their saved column setup — others see their own.

What personalisation stores

By default, DataGrid2 personalization stores:

1.Visible/hidden state of columns

2.Column order

3.Column size

4.Sort order

It does not automatically store filter values and filter types unless you configure those filters individually.


answered
0

There’s no built-in way to persist DataGrid2 column selections per user, but you can implement a relatively simple workaround.


You can hide the default column selector with custom CSS and add your own button that opens a small popup. This popup can list the available columns (for example with checkboxes). Store these column preferences in a persistent entity(you will create) that wraps the DataGrid2. Then bind each column’s visibility in the grid to the values stored in that entity. When the user closes the popup, save their preferences.


By associating this persistent entity with Account, you can support per-user column preferences. This is a high-level approach, but it provides a flexible and reusable solution.


answered