How to delete pending changes in ui5?

Viewed 4212

I get three pending changes from oModel.getPendingChanges(), oModel is sap.ui.model.odata.v2.ODataModel

{
    {
        ASet('id1') : {id: 1}
    },
    {
        BSet('id1') : {id: 1}
    },
    {
        CSet('id1') : {id: 1}
    }
}

I just want submit ASet. B and C changes is from ComboBox select. I have three ComboBoxes that are related to each other. I used binding to solve that.

<ComboBox
    id="theSecondSelect"
    selectionChange="onChange"
    enabled="false"
    showSecondaryValues="true"
    value="{
        path: 'propertySetId',
        type: '.Utils.mandatoryValueType'}">
</ComboBox>

<items> is dynamically binding in controller.

I've even tried

for(var sBindingPath in oChanges) {
    if(sBindingPath.indexOf("ASet") === -1) {
        delete oModel.mChangedEntities[sBindingPath];

    }
}
console.log(oModel.getPendingChanges());

I can see that pending changes has already been deleted, but the three requests still sent.

Any suggestion?


Update:

Remove pending changes by

_resetSelectChanges: function() {
    var oChanges = this._oModel.getPendingChanges();

    for (var sBindingPath in oChanges) {
        if (sBindingPath.indexOf("ControlIoTImplementationSet") === -1) {
            this._oModel.resetChanges(["/" + sBindingPath]);
        }
    }
}

enter image description here

But it will appear again after I close the form dialog.

enter image description here

1 Answers

See the API description of the resetChanges method here.

The method takes an array of strings as its parameter. Each string is a path of an entity which should be reset.

Sample call:

oModel.resetChanges(["/BSet('id1')", "/CSet('id1')"]);

This resets the changes of the two given entities. Thus only the changes to your ASet('id1') entity should be submitted.

Related