Skip to Content
0

SAP UI5 Modifying an Odata model obtained from manifest before setModel()

Dec 07, 2017 at 02:42 PM

53

avatar image
Former Member

I am creating my first SAP UI5 app and I have a need where i want to set an additional property to the data returned from an Odata service before i set it as a model to in the table view

However i am unable to access the data as the getProperty returns an empty object. Below is the code on the onInit() method of my controller . I am obtaining the model from my manifest.json as it looks a clean way to do things.

var rList = this.getOwnerComponent().getModel("Entities");
var localPromise = this.getPromise(rList, "/");
localPromise.done(function() {
    console.log(rList.getProperty("/"));
    // here i would like to do the manipulations and then set the view      
 }.bind(this));
},

i assume the getPromise method must take care of the asynchronous execution part:

getPromise: function(oModel, pathToTestForData) {
            var deferred = $.Deferred();
            if (oModel.getProperty(pathToTestForData))
                deferred.resolve(); //Data already loaded
            else
                oModel.attachRequestCompleted(deferred.resolve); 
//Waiting for the event
            return deferred.promise();
        } 

What i want to do is the following:

1) make the Odata two way bind.

2) set another property : anotherProperty:false on each returned Odata record

However as rList.getProperty("/")inside the done of the promise is empty, i am at a roadblock, Also how to access the data (if it was there)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers