Skip to Content
0
Former Member
Aug 12, 2015 at 10:34 AM

How to access data from multiple models

485 Views

Hi

I am trying to create couple of oData models in my control.

var oModel = new sap.ui.model.json.JSONModel("http://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json");

sap.ui.getCore().setModel(oModel,"customers");

var oModel1 = new sap.ui.model.json.JSONModel("http://services.odata.org/V3/Northwind/Northwind.svc/Products?$format=json");

sap.ui.getCore().setModel(oModel1,"products");

I am trying to access the value of these odata models like below

var otemplate = new sap.ui.commons.TextView({text:"{customers>ContactName}"})

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "Contact Name"}),

visible: true,

template: otemplate

}));

var oControl = new sap.ui.commons.TextView({text:"{customers>ContactTitle}"})

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "Contact Title"}),

visible: true,

template: otemplate

}));

I am unable to success, and my browser not throwing any errors.

Anyone help?

Thanks

Prasad