gpt4 book ai didi

javascript - 将表中的多行保存到后端 SAPUI5

转载 作者:行者123 更新时间:2023-12-03 02:35:30 26 4
gpt4 key购买 nike

我在将多行保存到后端时遇到问题。我不知道如何批量发送所有行,因此我尝试一次发送每一行,但它在将最后一行放入 oEntry 后命中。

submitButtonPress: function() {
var oModel = this.getModel();
var hasChanges = oModel.hasPendingChanges();

if (hasChanges) {
var mcJson = {};
//get only rows with changes
var modelChanges = oModel.getPendingChanges();
mcJson = modelChanges;

var mcJsonLength = Object.keys(mcJson).length;
var mcJsonKey = Object.keys(mcJson);
var officeCode = this.byId("officeCombo").getValue();
var oEntry = {};

//for each row get data
for (var i = 0; i < mcJsonLength; i++) {
var item = mcJsonKey[i];
var obj = modelChanges[item];
var estDate = this.convertDate(obj.ESTIMATE_DATE);

oEntry.MRU_ID = obj.EST_MRU_ID.toString();
oEntry.ESTIMATE_PRCT = obj.ESTIMATE_PRCT;
oEntry.INSTALL_READ = obj.INSTALL_READ;
oEntry.PLAN_ESTIMATE = obj.EST_INSTALL;
oEntry.MRU_DATE = estDate;
oEntry.OFFICE_CODE = officeCode.toString();*/


oModel.create("/MRU_ESTSet", oEntry, {
success: function(oData, response) {
sap.m.MessageBox.alert("MRU: " + oEntry.MRU_ID + " EST DATE:" + oEntry.MRU_DATE + " SAVED!");},
error: function(oError) {
sap.m.MessageBox.alert("Error Saving Entries!!");
}
});

}
} else {
sap.m.MessageBox.alert("No Changes To Submit");
}

}

最佳答案

如果您使用的是 oDataModel V2,那么您可以简单地执行以下操作:

oModel.submitChanges() 

这将批量发送对模型所做的所有更改。

submitChanges method documentation

关于javascript - 将表中的多行保存到后端 SAPUI5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48549023/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com