1
votes

is there a way to save the columnsettings of a SAPUI5-Table? if the user logout and relog again the table properties should be saved. what i have to do is to save the column settings which can be manipulated by user interaction.

Property: showColumnVisibilityMenu:true

i'm using sap.ui.table.Table

var oTable = new sap.ui.table.Table({
    title: "Table Example",
    selectionMode: sap.ui.table.SelectionMode.Single,
    showColumnVisibilityMenu:true, // those settings should be saved
});

actually i've found an example here to preview the selection of the columns (hide or show):

http://jsbin.com/ceduc/1/edit?html,js,output

So when the user decides to hide the column "Key1 Label" (figure below) and want to logout and relog again, the column shouldn't be visible. the configuration of the table columns should be saved for a user. how to do that?

enter image description here

2

2 Answers

2
votes

It depends on how exactly do you want to persist the view settings and on what backend you have.

If you have an ABAP backend which has the unified shell services (delivered as part of Fiori), then you can use the standard Personalization controller / services to persist the settings. See this demo, the UI5 documentation and the unified shell service docu.

If you have any other type of backend or you don't want to use the personalization services, then you should save the visibility of the columns inside a (dedicated) model. Then you can save the content of this model on your backend (by simply sending it to a dedicated REST service and persisting it e.g. in the database). When the user logs back in, you can read this model and simply restore it.

Another possibility would be to save it in the local storage of the browser. You still need the model from above, but instead of sending the data to the backend via AJAX, you simply save it to the local storage and load it from there when needed.

2
votes

You can make use of SAP's standard Shell personalization Service. Here is how I would do it.

  • Use Personalization Dialog (sap.m.P13nDialog) for managing Table's options
  • Get standard personalization service provider var oProvider = sap.ushell.Container.getService("Personalization").getPersonalizer(oPersId);
  • Connect your table with personalization provider and activate var oTablePersoController = new sap.m.TablePersoController({ table: oTable, persoService: oProvider }).activate(); This will automatically take care of saving and retrieving variants/personalization.
  • Launch the Personalization Dialog upon user cliking the corresponding button

You may use sap.ui.table.TablePersoController for sap.ui.table.Table