SAPUI5 - Batch Operations - how to do it right?

你离开我真会死。 提交于 2019-11-28 01:26:07
oModel.addBatchChangeOperations(batchChanges);
oModel.setUseBatch(true);

In case you need set a breakpoint in backend for batch operations, just set a break point in method CHANGESET_BEGIN or CHANGESET_END.

Post my POST code for sap.ui.model.odata.v2.ODataModel

"models": { "": { "dataSource": "mainService", "preload": true, "settings" : { "useBatch" : true, "defaultBindingMode": "TwoWay", "defaultCountMode" : "None", //default is sap.ui.model.odata.UpdateMethod.Merge "defaultUpdateMethod" : "Put" } } }

var sPath = oView.getBindingContext().getPath();
oModel.setDeferredGroups(["editGroup"]);
oModel.update(sPath, oData, {groupId: "editGroup"});
oModel.update(sPath, oData2, {groupId: "editGroup"});
oModel.submitChanges({
    groupId: "editGroup",
    success: this.successCallback, 
    error: this.errorCallback
});

Actually, v2.ODataModel will useBatch by default, use update()/create()/delete() without setDeferredGroups() and submitChanges() is OK. But in that way, I will get callback for each request, I use submitChanges to merge the responses to one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!