on 08-14-2017 9:38 AM
HI friends,
I'm using the SAP Web IDE version 160128 (local installation).
For update backend data I'm trying to use deffered groups, but unfortunately I faced an issue.
I want to collect all user input changes and then submit them on Save button click.
So, code sample from controller:
var oModel = this.getView().getModel();
oModel.setUseBatch(true); // Enable batch
oModel.setRefreshAfterChange(false); // Ban of refresh after change
oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay); // Set RwoWay binding mode as default
oModel.setChangeGroups({ //Set change group
"AgentSet": { groupId: "grpId", changeSetId: "chgId", single: false }
});
oModel.setDeferredGroups(["grpId"]); // Set group as deffered
Sample from my XML view:
<Input id="description"
value="{
path: 'Description',
mode: 'TwoWay',
parameters: { groupId: 'agnhdr', changeSetId: 'chgId' }
}"
liveChange="onICC"
change="onInputChange"/>
Creating of new entry works fine, there are no request:to backend:
oModel.createEntry("/AgentSet", {
properties: { Id: "", Description: "New entry" },
groupId: "grpId",
changeSetId: "chgId"
});
But when I change Input field of existing entry (or call method oModel.setProperty() for One way binding mode) it is directly sending an Batch request to backend without calling SubmitChanges()
So, could anybody help me to solve this issue? I didn't find any info about possible extra settings (except setDeferredGroups()) for deferred update.
Also callback functions "Success" and "Error" doesn't trigger on submit changes:
oModel.submitChanges({
success: function(oData, oResp){
console.log(oData); console.log(oResp);
}, error: function(oError){ console.log(oError);
groupId: "grpId"
});
To solve last I'm using attachment of event "requestCompleted", but I don't like this solution:
oModel.attachEventOnce("requestCompleted", null, function(oEvt){
console.log(oEvt.getParameters());
if (oEvt.getParameters().response.responseText){
var oResp = JSON.parse(oEvt.getParameters().response.responseText);
}
console.log(oResp);
var oData = oView.getBindingContext().getObject(); console.log(oData);
});
Hope someone could help me
BR,
Boris
Found my mistake!
I should point the entity TYPE name, NOT entity SET here:
oModel.setChangeGroups({
"AgentSet": { groupId: "grpId", changeSetId: "chgId", single: false }
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.