on 10-25-2021 3:19 AM
Data has been changed in the form and submitBatch has successfully updated the server data. oBinding.hasPendingChanges()
should be false but stays true even though the batch has been successfully submitted.
Why is oBinding.hasPendingChanges() still returning true when it should be false?
groupProperties.Submit can be either API or Auto and the issue persists
Code:
var oBinding = this.byId("idMainTable").getBinding("items");
var oThis = this;
var fnSuccess = function() {
oBinding = this.byId("idMainTable").getBinding("items");
var bChangedAfter = oBinding.hasPendingChanges()
//bChangedAfter should be = false but is still true!! Why?
//The data has been updated correctly at the server.
}.bind(oThis);
var fnError = function(oError) {
//handle error
MessageBox.alert(oError.message);
}.bind(oThis);
if (oBinding.hasPendingChanges()) {
oThis.getView().getModel().submitBatch("ladderList").then(fnSuccess, fnError);
} else {
//Do nothing - no changes to Submit
}
Hi,
You can check the pending changes with the getPendingChanges() method.
Maybe you need to rebind the table?
You should also check the documentation about #hasPendingChanges(). Do you modify the model with create, update or remove? In this case you should set the optional parameter bAll to true.
hasPendingChanges
Checks if there exist pending changes in the model.
By default, only client data changes triggered through: #createEntry #setProperty are taken into account.
If bAll
is set to true
, also deferred requests triggered through: #create #update #remove are taken into account.
hasPendingChanges(bAll?) : boolean
Update:
In ODataV4 hasPendingChanges has the parameter of the group ID. In Your case, it should be: "ladderList"
hasPendingChanges(sGroupId?) : boolean
A group ID as specified in sap.ui.model.odata.v4.ODataModel, except group IDs having sap.ui.model.odata.v4.SubmitMode.Direct; if specified, only pending changes related to that group ID are considered (since 1.70.0)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thorsten,
Thank you very much for your suggestions. As you noticed I am using oDataModel.V4. I have tried supplying the GroupId but it does not seem to change anything. The table binding itself is already associated with that GroupID ("ladderList") but the problem is the same whether or not I have "ladderList" as a paramter to hasPendingChanges.
If I edit a column in the table hasPendingChanges correctly returns true.
Then I call oThis.getView().getModel().submitBatch("ladderList").then(fnSuccess, fnError) which succeeds. The data is updated on the server and reply is 200 in the Network pane.
But hasPendingChanges is still true and should be false since the server is updated.
I am wondering now about Odata V4. And whether I should revert to Odata V2. V4 seems to still have some limitiations and issues although does have some new features. Do you know if people are generally happy with V4?
Thanks again for your help.
Mel
Hi Mel,
I found the List binding Parameter $$updateGroupId.
https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.odata.v4.ODataModel/methods/bindList
Maybe you need to add this parameter to your binding?
Like this?
https://embed.plnkr.co/plunk/qatUyq
this.getView().bindElement({
path: `/People('${decodedUserName}')`
, parameters: { $$updateGroupId: batchGroupId }
, events: { dataRequested: () => this.byId("page").setBusy(true),
dataReceived: () => this.byId("page").setBusy(false)
}
});
Hi Thorsten,
Thanks again for your comment. Unfotrunately I have already set the $$updateGroupId for the Binding.
<Table id="idMainTable" inset="false" mode="SingleSelectMaster" includeItemInSelection="false" selectionChange="onSelectionChange"
items="{path: '/UDO_K2P_APRV_LADDER',
parameters: {$$updateGroupId : 'ladderList', $orderby : 'Code'},
events: {dataReceived : '.onDataReceived', change: '.onDataChange'}
}" width="500px" >
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.