[英]How to refresh(reload) SAPUI5 oModel (oData)
I have a following problem. 我有以下问题。 I am able to properly call function UserDelete to delete a row with user data in table on SAP side but deleted object is still in oModel. 我能够正确调用函数UserDelete来删除SAP端表中包含用户数据的行,但是删除的对象仍在oModel中。 How to refresh or destroy and recreate oModel ? 如何刷新或销毁并重新创建oModel? I tried to use : 我尝试使用:
oModel.destroy();
var oModel = new sap.ui.model.odata.ODataModel("http://plaut0001.plaut.pl:8000/sap/opu/odata/sap/ZUSERINFO_SRV/",true,"developer","gliwice");
sap.ui.getCore().setModel(oModel);
but after this i got following error: Uncaught TypeError: Cannot read property 'dataServices' of undefined 但是在此之后,我得到以下错误:未捕获的TypeError:无法读取未定义的属性'dataServices'
below is the code I use to call function deleting user on SAP side: 下面是我用来在SAP端调用函数删除用户的代码:
//handle delete button
handleDelete : function(evt) {
var context = evt.getSource().getBindingContext();
var oModel = sap.ui.getCore().getModel();
oModel.callFunction('UserDelete', 'POST',
{Userid : context.getProperty("Userid")},
null,
function(){sap.m.MessageBox.show("Pomyślnie usunięto");},
function(){sap.m.MessageBox.show("Błąd");}
);
sap.ui.getCore().getEventBus().publish("nav", "to", {
viewId : "app.details.Empty",
data : ""
});
You have to bind the service after the remove command in your code. 您必须在代码中的remove命令之后绑定服务。 Please provide sample Jsbin link that you have already tried. 请提供您已经尝试过的示例Jsbin链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.