Skip to Content
0
May 22, 2018 at 11:22 AM

SAP UI5:Placeholder in view.js for the data fetched from database

185 Views

Hi Experts,

I am working on ui5 and 'HANA. I wanted to fetch the data from the database and place it in the ui5. For this I have done the following:

util.js
var a= "/xxx/xxx/Services/getxxx.xsjs?YEAR=2018&ALL=1";
var oModel = new sap.ui.model.json.JSONModel();
$.ajax({
url: targetMay,
method: "GET",
cache: false,
success: function(data)
{ for(var item in data.ALL)
{ if ((data.ALL[item]["xxx"] > start) && (data.ALL[item]["xxx"] <= end)) {
var x1=data.ALL[item]["xxx"];
var x2=data.ALL[item]["xxx"];
var x3=data.ALL[item]["xxx"];
var x4=data.ALL[item]["xxx"];
var data_var = {
x1_var: "x1",
x2_var: "x2",
x3_var: "x3",
x4_var:"x4"
};
return data_var; } } } });

view.js

var landscapeImageVerticalLayout = new sap.ui.layout.VerticalLayout();
var oTable = new sap.ui.table.Table();


var aVar = jQuery.sap.require("js.util1");


var oModel = new sap.ui.model.json.JSONModel();
// set the data for the model
oModel.setData({modelData: aVar});
// set the model to the core
sap.ui.getCore().setModel(oModel);


oTable.addColumn(new sap.ui.table.ColumnHeader({
label: new sap.ui.commons.Label({text: "START DATE"}),
template: new sap.ui.commons.TextField({value:"{aVar.startdate_var}"}) }));

oTable.bindRows("/modelData");

landscapeImageVerticalLayout.addContent(oTable); return landscapeImageVerticalLayout;
};


I am not able to fetch these data

var x1=data.ALL[item]["xxx"];
var x2=data.ALL[item]["xxx"];
var x3=data.ALL[item]["xxx"];
var x4=data.ALL[item]["xxx"];

in the ui in a table.

Could you recommend if there is any solution for the code.

If I am trying to fetch the data via using alert example:

alert(data.ALL[item][xxx"]); this is working, so it means the database connections are fine.

It would be great if you could help with this issue