sapui5 ajax,SAPUI5 sap.ui.table.Table(SAPUI5 sap.ui.table.Table)

SAPUI5 sap.ui.table.Table(SAPUI5 sap.ui.table.Table)

有没有办法保存SAPUI5-Table的列设置? 如果用户注销并再次重新登录,则应保存表属性。 我要做的是保存可以通过用户交互操纵的列设置。

属性: showColumnVisibilityMenu:true

我正在使用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

});

实际上我在这里找到了一个例子来预览列的选择(隐藏或显示):

因此,当用户决定隐藏“Key1 Label”列(如下图所示)并想要再次注销和重新登录时,该列不应该可见。 应为用户保存表列的配置。 怎么做?

FUWqQ.png

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):

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?

FUWqQ.png

原文:https://stackoverflow.com/questions/43617648

更新时间:2020-12-10 15:12

最满意答案

这取决于您希望如何持久保存视图设置以及您拥有的后端。

如果您的ABAP后端具有统一的shell服务(作为Fiori的一部分提供),那么您可以使用标准的Personalization控制器/服务来保留设置。 请参阅此演示 , UI5文档和统一shell服务文档 。

如果您有任何其他类型的后端或者您不想使用个性化服务,那么您应该在(专用)模型中保存列的可见性。 然后,您可以在后端保存此模型的内容(只需将其发送到专用的REST服务并将其保存在数据库中)。 当用户重新登录时,您可以阅读此模型并简单地将其恢复。

另一种可能性是将其保存在浏览器的本地存储中。 您仍然需要上面的模型,但不是通过AJAX将数据发送到后端,而是将其保存到本地存储并在需要时从那里加载。

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.

相关问答

我有点困惑,因为你的解释不明确,但让我们看看你的代码有一些有价值的评论: 首先,我建议在生产使用时使用sap.m.Table对象来创建表。 它具有响应性,支持移动设备,并且在官方的Fiori应用程序中也得到了广泛的使用和维护。 你的绑定工作正常。 由于JSONModel默认设置为双向绑定(但我应该看到项目的bootstrap部分以确保),输入中输入的数据会在模型中自动更新。 因此,如果您想创建一个转发信息的发送按钮,您不必访问表,行甚至列; 只需处理JSON模型。 //Input1.attachC

...

您可以异步加载UI5资源。 使用data-sap-ui-preload="async"

data-sap-ui-theme="sap_bluecrystal"

...

这一行var index = tableId.getSelectedIndex(); 在您的方案中返回-1。 此外,要删除一行,您需要指定removeSelectionInterval(index,index); 第二个参数不是要删除的位置数量。 是indexTo ,所以你想从选定的行中移除到选定的行。 从事件中获取行索引对你来说会更好。 尝试这个: var iIndex = oEvent.getSource().getParent().getIndex();

var oTable = this.

...

在index.html中的data-sap-ui-libs声明中, sap.ui.model和sap.ui.model.json是不必要的。 删除语句中的两个库。 试试吧:

data-sap-ui-libs="sap.ui.commons, sap.m, sap.ui.table"

data-sap-ui-theme="sap_bluecrystal">

...

为什么不使用OverflowToolbar而不是工具栏? 官方响应式工具栏https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.OverflowToolbarFooter/preview 如果你不喜欢它,并且需要你描述的这种“弹出式”行为,我想你可以在工具栏中放置一个FlexBox,并根据“设备”模型设置方向属性。 使用表达式绑定将是这样的: new sap.m.FlexBox({

direction: "{

...

请找到更新的功能代码,希望这有助于 sap.ui.getCore().attachInit(function() {

//Define some sample data

var aData = [

{lastName: "Dente", name: "Al"},

{lastName: "Friese", name: "Andy"},

{lastName: "Mann", name: "Anita"},

{lastNam

...

您忘了在视图中return您的控件。 把所有东西放在周围的容器中,然后像这样返回它: createContent : function(oController) {

// create controls like you do it right now

// but rather than using placeAt put them in one container

// and return the container. For Example:

var con

...

[...]自动填充周围容器的高度[...] 您的周围容器是视图,因此您必须将其高度也设置为值(例如100%) this.setHeight("100%");

并且您的视图将被设置为uiArea-div,因此这个也需要一个高度(例如500px)

通过这些更改,它现在可以按预期工作 [...] automatically fills the height of the surrounding containe

...

试试这个解决方案吧。 template: new sap.ui.commons.TextField({

value: {

path: 'RATE', //Binding Context field here

formatter: function(value){

return '1: ' + value;

}

}

})

Try this solution it will work. template: new sap.

...

这取决于您希望如何持久保存视图设置以及您拥有的后端。 如果您的ABAP后端具有统一的shell服务(作为Fiori的一部分提供),那么您可以使用标准的Personalization控制器/服务来保留设置。 请参阅此演示 , UI5文档和统一shell服务文档 。 如果您有任何其他类型的后端或者您不想使用个性化服务,那么您应该在(专用)模型中保存列的可见性。 然后,您可以在后端保存此模型的内容(只需将其发送到专用的REST服务并将其保存在数据库中)。 当用户重新登录时,您可以阅读此模型并简单地将其恢

...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值