Save filter criteria in DataGrid2

2
Hi all, is it possible to save the filter criteria in DataGrid2?    Example scenario: I have a table with many columns that several users use, each of them only wants to see just the columns that are relevant to them. However, each time I open the page, the filter criteria are reset.    I have found this option in the settings, but without success:     Many thanks in advance! Best regards Fynn
asked
3 answers
3

I’l explain it here since it is more readable.

The unlimited config string needs to be on it’s own object. It has nothing to do with the stuff you are showing in the grid. You could have a helper object that is associated with the account of the user (so that every user has it’s own settings).

On your page, you need a dataview that has your helper object. Inside of this dataview, you can now have your datagrid 2. The easiest way (without any custom logic) is to set it up like this:

ConfigString is the attribute I am using on my helper object that is shown in the dataview in which the datagrid2 is placed. OnChange I want to save the changes without closing the page. This ensures, that every change myde by the user will directly be stored in the config object.
You can also apply custom logic when calling amicroflow, but this example covers the basic functionality.

answered
1

Please download “Data widget”’s most recent version, 2.0.2, wrap your datagrid in a dataview, and see this for the description: https://docs.mendix.com/appstore/modules/data-grid-2.

Just now I have used this for the first time, and it works, but has it drawbacks:

  • Logic states that you store the personal setting of a datagrid at the person/useraccount that is currently logged in. Yet datagrid2 can only use the direct parent as datasource, preventing you from wrapping the datagrid in a CurrentUser-dataview if the datasource was already over association. So: hopefully 1) Mendix will enable Datagrid2 to use an association of parent’s parent-level, or higher; 2) the attribute gets added to System/UserAccount (still incorrectly called ‘User’) and until that time: Instead of having datagrid2’s datqasource being ‘Over association’ make it ‘by ..flow’
  • The content of attribute personalization looks like: [{"column":"Full name","sort":false,"sortMethod":"asc","hidden":false,"order":0},{"column":"Personel number","sort":false,"sortMethod":"asc","hidden":false,"order":1},{"column":"Start date","sort":false,"sortMethod":"asc","hidden":false,"order":2},{"column":"Left us at","sort":false,"sortMethod":"asc","hidden":false,"order":3},{"column":"Salary","sort":false,"sortMethod":"asc","hidden":false,"order":4},{"column":"Holidays till year end","sort":false,"sortMethod":"asc","hidden":false,"order":5}]. So it seems to only be able to contain one datagrid setting per personalization-attribute. A test showed that two separate Datagrids using the same attribute for storing the personalization-attribute overwrite each other. So: create one attribute for each datagrid you want personalized.

To get it implemented correctly, I added an entity that I associated to ‘Person’ (see module ‘Person’ in the marketplace, Systemuser):

Person 1←----

Now I can wrap my datagrid2 in a dataview that, for its datasource, retrieves the object by elementname.

MarketModule Person released today has this setup as well. If you don’t have or want that module, connect PersonalSettings to System.UserAccount

answered
4

Did you place your DataGrid2 inside of a dataview that has the config object?

If not, you need to do that. This vonfig object needs an attribute (unlimited string) in which DG2 is storing the configuration. You can have one config object per app, one per user or even multiple ones per user. This logic need to be created by you, for example in datasource microflows.

answered