on 11-17-2016 9:26 AM
Hello,
I'm not expert on SAPUI5 but I already build Fiori Applications starting with the generated apps from SAP Webide. Maybe this is the reason I missed something, but this time I used the last version of FIORI template and it doesn't work as I expect.
Model is define in manifest.json :
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "customerexpiredprices.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true,
"settings": {
"defaultBindingMode": "TwoWay",
"useBatch": true,
"defaultCountMode": "Inline"
}
}
},
I want to delete multiple lines of an entity, but I want to do it in one request, this is why I used submitChanges to call the batch request and handle the succes or error event from the submitChanges :
onDeletePress: function(oEvent) {
var self = this;
//Get Model
var oModel = this.getView().getModel();
//get selected lines
var oSelectedContextPaths = this.byId("idMaterialList").getSelectedContextPaths();
//Call delete for every lines
if (oSelectedContextPaths.length === 0) {
MessageBox.error(this.getResourceBundle().getText("noSelection"));
} else {
oSelectedContextPaths.forEach(function(sPath) {
this.remove(sPath);
}, oModel);
}
this.getModel("detailView").setProperty("/busy", true);
oModel.submitChanges({
success: function(oData, sResponse) {
MessageToast.show(self.getResourceBundle().getText("deleteConditionSuccess"));
self.getView().getModel().refresh(true);
self.getModel("detailView").setProperty("/busy", false);
},
error: function(oError) {
self.getModel("detailView").setProperty("/busy", false);
}
});
},
Neither Success nor error functions defined in submitChanges method are called. Althought if I attach success function in the remove method it is called but for every lines.
I didn't expected this behavior, and i'm pretty sure I did something similar before and the succes was called from the submitChanges.
Please help...
I doubt if anything is happening at all when 'submitChanges' is called. Verify that in the Network tab.
When this.remove() is called, I suspect that 'Delete' is called there itself.
If you want 'submitChanges' to trigger the call, you need to make use of API 'setDeferredGoups'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is an old thread, but anyway:
A call to oModel.remove (without batchgroup) usually triggers a request right away. I personally think this is a bug..
Regards Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe I wasn't clear enough but yes there are batch request sent, but it doesn't seems that it is sent by the submitChanges method as I don't get the callback.
Anyway, thanks a lot, if I define my own deferred group, it works !
Looked like this :
var self = this;
//Get Model
var oModel = this.getView().getModel();
//get selected lines
var oSelectedContextPaths = this.byId("idMaterialList").getSelectedContextPaths();
//Define group ID
oModel.setDeferredGroups(["priceDeleteGroup"]);
//Call delete for every lines
if (oSelectedContextPaths.length === 0) {
MessageBox.error(this.getResourceBundle().getText("noSelection"));
} else {
oSelectedContextPaths.forEach(function(sPath) {
this.remove(sPath, { groupId: "priceDeleteGroup"});
}, oModel);
}
this.getModel("detailView").setProperty("/busy", true);
oModel.submitChanges({
groupId: "priceDeleteGroup",
success: function(oData, sResponse) {
MessageToast.show(self.getResourceBundle().getText("deleteConditionSuccess"));
self.getView().getModel().refresh(true);
self.getModel("detailView").setProperty("/busy", false);
},
error: function(oError) {
self.getModel("detailView").setProperty("/busy", false);
}
});
What I still don't understand is why I didn't need this before. And i'm pretty sure it was working without explicitlly define the groupId.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.