Skip to Content
0
Former Member
Jul 19, 2013 at 02:56 PM

sapui5 table shows only the same record

1375 Views

I have created a webservice using SEGW and trying to bind data using oData protocol in SAPUI5 to display items belonging to a certain PO.

My View looks as below:

createContent : function(oController) {      jQuery.sap.require("sap.ui.table.Table");      //Create table control with properties      var oTable = new sap.ui.table.Table({          width : "100%",          rowHeight : 50,          title : "Lst of Items",          selectionMode : sap.ui.table.SelectionMode.None      });      oTable.addColumn(new sap.ui.table.Column({          label : new sap.ui.commons.Label({          text : "PO Number"          }),          template : new sap.ui.commons.TextView({          text : "{PoNumber}"          }),          }      ));      oTable.addColumn(new sap.ui.table.Column({          label : new sap.ui.commons.Label({          text : "Item"          }),          template : new sap.ui.commons.TextView({          text : "{PoItem}"          }),          }      ));      //Filter values for a certain PO      var aFilter = [];      aFilter.push( new sap.ui.model.Filter("PoNumber", sap.ui.model.FilterOperator.EQ, "4500000043") );      oTable.bindRows({          path: "/PurchaseOrderItemCollection",          filters: aFilter          });      return oTable;}

The data model is created in controller in the following way:

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, false, "user", "passw");
sap.ui.getCore().setModel(oModel);

The otuput should be as follows: PONumber POItem

4500000043 0010

4500000043 0020

But what I get is: PONumber POItem

4500000043 0020

4500000043 0020

So it shows the last item twice and doesn't show the first item. If I put a break point in my web service code then in the internal table that is passed to the exporting parameter looks correctly. Also If I use the following link to display the data in the browser:

http://address:port/sap/opu/odata/sap/Z_PORDER_SRV/PurchaseOrderItemCollection?$filter=PoNumber eq '4500000043'&$format=json

It shows both items:

Attachments

pastedImage_9.png (14.0 kB)