srz
srz

Reputation: 129

PendingChanges only for specific OData Entities

Is there a way to check only a specific entity of a OData-Model for pending changes? Pending changes does not have any input parameters, also I'm not sure if DeferredGroups would work for this.

My only idea is using ODataModel.getPendingChanges() and make a string comparison on the results. But maybe there is a more elegant option.

Upvotes: 1

Views: 1426

Answers (1)

srz
srz

Reputation: 129

Finally I found a way to do this with a custom pendingChanges-Method.

_hasPendingChanges: function() {
    var oPendingChanges = this._oODataModel.getPendingChanges(),
        sValue = "MyEntitySetToIgnore",
        bReturn;

        var aPendingChanges = $.map(oPendingChanges, function(value, index) {
            return [index];
        });


        for (var i = 0; i < aPendingChanges.length; i++) {
            if (aPendingChanges.toString().startsWith(sValue)) {
                bReturn = this.DoSomeSpecialThingsHere();
            } else {
                return true;
            }

            if (bReturn) {
                return true;
            }
        }

        return false;
    },

You can also adapt the $.map function to return the pending changes of a specific entityset by returning the value instead of the index. Therefore you are able to extend this function and use this for checking a specific attribute of a specific entity set.

Upvotes: 1

Related Questions