Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

OdataModel as named Model and databinding

$
0
0

Hello,

 

When we create an odatamodel (not a named model), the textfield in the view is populated with a value. So everything works fine.

However when we create the odatamodel as a named model there seems to be no way to do a property binding.

Let me give you an example with the "http://services.odata.org/Northwind/Northwind.svc/" service .

 

 

Controller:

 

 var oModel = new sap.ui.model.odata.ODataModel("http://services.odata.org/Northwind/Northwind.svc/");  sap.ui.getCore().setModel(oModel);

 

View:

 

var oTf = new sap.ui.commons.TextField('input1');  oTf.bindElement("/Categories(1)");   oTf.bindProperty("value", {     path: "CategoryName"  });  return oTf;

 

 

 

However : when we want the odatamodel to be a named model, the value in the textfield is not populated anymore.

 

Controller:

  var oModel2 = new sap.ui.model.odata.ODataModel("http://services.odata.org/Northwind/Northwind.svc/");  sap.ui.getCore().setModel(oModel2, "testModel");

 

 

View:

  var oTf = new sap.ui.commons.TextField('input1');  oTf.bindElement("/Categories(1)");   oTf.bindProperty("value", {      path: "CategoryName",      model: "testModel"  });  return oTf;

 

 

We tried several settings with path like testModel>/Categories(1) but no luck.

Could anyone tell us how to use the oDataModel as a named model with regards to property binding?

Any help will be appreciated.

 

Regards,

Bert


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>