Hello Experts,
I am trying to display some data by consuming odata services by creating a project in eclipse,but table is coming as blank.
Can you please suggest where am i going wrong.
Please find the attached code below.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table"
data-sap-ui-theme="sap_ux">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("zsap_ui5_project");
var app = new sap.m.App({initialPage:"idfirst1"});
var page = sap.ui.view({id:"idfirst1", viewName:"zsap_ui5_project.first", type:sap.ui.core.mvc.ViewType.JS});
app.addPage(page);
app.placeAt("content");
var oTable = new sap.ui.table.Table({
id : 'oTable',
title : "Table Example",
visibleRowCount : 15,
firstVisibleRow : 5,
selectionMode : sap.ui.table.SelectionMode.Single
});
//Define the columns and the control templates to be used
var oColumn = new sap.ui.table.Column(
{
label : new sap.ui.commons.Label({text : "USER ID"}),
template : new sap.ui.commons.TextView().bindProperty("text","Userid"),
sortProperty : "Userid",
filterProperty : "Userid",
width : "100px"
});
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "First Name"}),
template : new sap.ui.commons.TextField().bindProperty("value","Firstname"),
sortProperty : "Firstname",
filterProperty : "Firstname",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Last Name"}),
template : new sap.ui.commons.TextField().bindProperty("value","Lastname"),
sortProperty : "Lastname",
filterProperty : "Lastname",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Email Id"}),
template : new sap.ui.commons.TextField().bindProperty("value","Emailid"),
sortProperty : "Emailid",
filterProperty : "Emailid",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Phone"}),
template : new sap.ui.commons.TextField().bindProperty("value", "Phone"),
sortProperty : "Phone",
filterProperty : "Phone",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Country"}),
template : new sap.ui.commons.TextField().bindProperty("value","Country"),
sortProperty : "Country",
filterProperty : "Country",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Salary"}),
template : new sap.ui.commons.TextField().bindProperty("value","Salary"),
sortProperty : "Salary",
filterProperty : "Salary",
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "IMAGE"}),
template : new sap.ui.commons.Image().setProperty("src","ganguly.jpg"),
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Firstname"}),
template : new sap.ui.commons.Button().bindProperty("text","Firstname"),
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Rating"}),
template : new sap.ui.commons.RatingIndicator().setProperty("value",2.5),
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Progess"}),
template : new sap.ui.commons.ProgressIndicator().setProperty("percentValue",90),
width : "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Checkbox"}),
template : new sap.ui.commons.CheckBox().setProperty("checked",true),
width : "100px"
}));
var oModel = new sap.ui.model.odata.ODataModel(
"proxy/sap/opu/odata/SAP/ZFETCH_DB_SRV", false, "fioriserver",
"server123");
oTable.setModel(oModel);
oTable.bindRows("/userSet");
oTable.placeAt("content1");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
<div id="content1"></div>
</body>
</html>
Thanks and Regards,
Ajay