cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind oDataModel to sap.ui.view

former_member190939
Participant
0 Kudos

Hi,

How to bind oDataModel to sap.ui.view?

Below is my code, I am not sure how to proceed further in order to see my data in my view.

sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", {

  createContent : function() {

  // create root view

  var oView = sap.ui.view({

  id : "app",

  viewName : "sap.ui.demo.myFiori.view.App",

  type : "JS",

  viewData : { component : this }

  });

var url = service + "/ES_GETSYS";//?$filter=Reqtyp eq 'FUL'";

var oModel = new sap.ui.model.odata.ODataModel(url, false, "user", "password");

oView.setModel(oModel);

return oView;

}

});

I got the error that ES_GETSYS is an entity set, not an entity type. So I removed the entity set and changed the above lines to:

var oModel = new sap.ui.model.odata.ODataModel(service, false, "user", "password");

oView.setModel(oModel);

return oView;

Now I don know how to bind the return data to oView?

Please help.

Best Regards,

Seyed Ismail MAC

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Seyed,

I am also new to SAPUI5. But acc to my knowledge we can bind the data available in the models to the controls .

for example if you want to bind the data to the table you can use "bindrows" fuction.

suppose you used a list in mobile applications the we can use "binditems" function

first of all you need to know about what are the binding types in SAPUI5 follow the below url

SAPUI5 SDK - Demo Kit

if you know about those then it is well and good.

I think We cannot  directly set the model(data from backend i.e. url) directly to the view . we can assign model to the any of the controls like tables or items in list 

Please let me know if i am wrong

Thanks&Regards

Ramu Vedula

former_member190939
Participant
0 Kudos

this is working... binding mock data to a view directly

// set data model on root view

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

oView.setModel(oModel);