Hello experts,
I'm new to SAPUI5 and am having trouble understanding Models and binding.
I have created an OData service on my backend.
http://[MY_SERVER]:[PORT]/sap/opu/odata/sap/ZUI5_MSS_MOBILE_ACTIVITY_SRV/zui5_mss_mobile_activitySet
This service works when I navigate to it directly, returning the data as an EntitySet.
I then try to call this OData service from my App as below. It is not clear to me why the app is failing -- I have tried passing the full path to the ODataModel constructor method but that does not seem to correct the issue. I assume the issue is with the Column binding; however I am struggling to understand how these are implemented in this context.
Can anyone provide help?
<script>
//This section creates the OData Model; it uses the address of the UI5 service
var oModel = new sap.ui.model.odata.ODataModel("sap/opu/odata/sap/ZUI5_MSS_MOBILE_ACTIVITY_SRV/");
sap.ui.getCore().setModel(oModel);
// Now I create a table with three columns
var oTable = new sap.ui.table.Table({
title: "MSS App Prototype",
visibleRowCount: 6,
selectionMode: sap.ui.table.SelectionMode.Single,
navigationMode: sap.ui.table.NavigationMode.Paginator,
fixedColumnCount: 3,
enableColumReordering: true,
width:"100 %"
});
// Each column is bound to the OData input by the “template” quality; but I suppose this is where it goes wrong?
oTable.addColumn(new sap.ui.table.Column({
id: "sname",
label: new sap.ui.commons.Label({text: "Name"}),
template: new sap.ui.commons.TextView({text: {sname}}),
}));
oTable.addColumn(new sap.ui.table.Column({
id: "activity",
label: new sap.ui.commons.Label({text: "Activity"}),
template: new sap.ui.commons.TextView({text: {activity}}),
}));
oTable.addColumn(new sap.ui.table.Column({
id: "act_long",
label: new sap.ui.commons.Label({text: "Act. Long"}),
template: new sap.ui.commons.TextView({text: {act_long}}),
}));
//Bind model
oTable.setModel(oModel);
// Bind rows
// Bind rows from the UI5 entityset path
oTable.bindRows({path:"/zui5_mss_mobile_activitySet"});
oTable.placeAt("content");
</script>