on 09-10-2014 1:02 PM
Dear All Gurus,
Need your expert knowledge in solving below simple matter.
I have created an oData with Header and Line item values for Purchase Order details. And I am able to successfully consume oData Service with below code.
OData.request({ requestUri: "[server URL - this request is with oData $expand query]",
headers:{"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token":"Fetch" },
method : "GET",
user: "[User]",
password: "[PW]" ,
recognizeDates: true,
},
function (data, response){ // response is successful and values are coming in "data" variable
//Data needs to be bound to SAPUI5 table and Below is my Coding
var oModel = new sap.ui.model.json.JSONModel();
sap.ui.getCore().setModel(oModel);
oModel.setData({modelData: data});
oTable1.setModel(oModel);
oTable1.bindRows("/modelData");
}
But this is not working...I know that I have done something wrong in binding data into table and expecting your valuable advice on this..
Hi,
Use OData model instead of jsonmodel.
var oModel = new sap.ui.model.odata.ODataModel();
Also open chrome console (function key F12) and do the trouble shooting.
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tharu,
did you define the service path pointing to the OData service when you create the ODataModel object (e.g. var oModel = new sap.ui.model.odata.ODataModel("http://www.mysite.com/services/myservice/", false); )?
You don't need the OData.request method call.
Please have a look to the API documentation (https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.model.odata.ODataModel.html).
Regards, Florian
Hi Tharu,
in the constructor of the ODataModel "class" you can add all information you need.
So your example should work nearly with following coding:
// create oDataModel and connect it to service
var oDataModel = new sap.ui.model.odata.ODataModel(<url to your service>, false, <user>, <password>);
// create table
var oTable = new sap.ui.table.Table();
// add a column to the table
oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text:"Test Column Header"}), template: new sap.ui.commons.TextField().bindProperty("value", "<value of oData Model part of path bound to rows (see below)>") }) );
// set oDataModel for table
oTable.setModel(oDataModel);
// bind path of oDataModel to table rows
oTable.bindRows("<path>");
Regards, Florian
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.