Skip to Content
0
Aug 27, 2013 at 08:32 AM

OdataModel as named Model and databinding

318 Views

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