Skip to Content
0
Jun 02, 2016 at 07:38 AM

SAPUI5 Analytical Table Binding issue

2596 Views

Hello Experts,


We need to design UI5 application by using Analytical Table because we need ALV features like Export, Grouping, Total, Sub Total, Sorting etc. So Designed ALV table by using AnalyticalTable Class but when we try to bind oData Service with Analytical Table, giving below error and not displaying output.( if oData service is not used then this Analytical table is displaying empty table wihtout any errors.)


Error in F12 Debugger is:

Error in AnalyticalBinding - The QueryResult 'ZInvDataSet' could not be retrieved. Please check your service definition.


I am able to use same oData Service for Normal table (Class: sap.ui.table.Table) and everything working fine but ALV features are not coming.


So please find JS code below and provide your suggestions to fix this issue.


View JS Code:


var oPanel = new sap.ui.commons.Panel('Panel');

var oLayout = new sap.ui.commons.layout.MatrixLayout('layout');

var oTable = new sap.ui.table.AnalyticalTable({id:this.createId("ALVTable")}).addStyleClass('alternate-color');

oTable.addColumn(new sap.ui.table.AnalyticalColumn({ Id: "InvNo",

label: new sap.ui.commons.Label({text: "Invoice No."}),

template: new sap.ui.commons.TextView().bindProperty("text", "InvNo").bindProperty("helpId","InvNo"),

resizable:false,

sortProperty: "InvNo",

filterProperty: "InvNo"

}));

oTable.addColumn(new sap.ui.table.AnalyticalColumn({ Id: "SuppInvDate",

label: new sap.ui.commons.Label({text: "Supp Inv Date"}),

template: new sap.ui.commons.TextView().bindProperty("text", "SuppInvDate").bindProperty("helpId","SuppInvDate"),

resizable:false,

sortProperty: "SuppInvDate",

filterProperty: "SuppInvDate"

}));


oPanel.addContent(oTable);

oLayout.createRow(oPanel);

this.addContent(oLayout2);


Controller JS Code:


onInit: function() {

var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZTEST_ODATA_SRV/", true);

var view = this.getView();

var oTable = view.byId("ALVTable");

oTable.setModel(oModel).bindRows("/ZInvDataSet");

},

Index HTML Code:

<!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.ui.commons,sap.ui.table"

data-sap-ui-theme="sap_bluecrystal">

</script>

<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

<script> sap.ui.localResources("ztest_alv"); var view = sap.ui.view({id:"idZtest11", viewName:"Testalv.ViewALV", type:sap.ui.core.mvc.ViewType.JS}); view.placeAt("content"); </script>

</head>

<body class="sapUiBody" role="application">

<div id="content"></div>

</body>

</html>