cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5:Unable to get oData model to work

Former Member
0 Kudos

Hi ,

I am trying to get the data from oDataModel before it gets bound to the list  , in the view  .I have tried to set my model in the attach request completed delegate method.

appC.oModel.attachRequestCompleted(function(evt){

                              alert("Request Completed" + "--");

                        var name = sap.ui.getCore().getModel().getData();

                                    console.log(name);

                                   });

I am invoking the REST service using oData Model constructor:

appC.oModel = new sap.ui.model.odata.ODataModel(sServiceUrl1,false, "usr", "pwd" , mHeaders);

I am expecting  variable name should have , the data of the collection , but I am always getting null.

Regards

Nidhideep Bhandari

Accepted Solutions (0)

Answers (2)

Answers (2)

arthursilva
Active Participant
0 Kudos

Hello,

You could try the following statement:


jQuery.ajax({

     url: url,

     type: "GET",

     dataType: "jsonp",

     success: function(data, textStatus, jqXHR) {

          var oModel = new sap.ui.model.json.JSONModel();

          oModel.setData(data);

     // insert your logic here

     },

     error: function(data, textStatus, jqXHR) {

     // insert your logic here

     }

  });

Kindly

Regards,

Arthur Silva

Former Member
0 Kudos

hi,

maybe "Using Factory Functions" will help: https://sapui5.hana.ondemand.com/sdk/#docs/guide/BindingAggregations.html

Regards

Stefan