Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

SAP UI5 table with JSON format service data is not working

$
0
0

Please check below code:

 

Controller:

onInit: function() {                 var oModel = new sap.ui.model.json.JSONModel();                       $.ajax({               type: 'GET',               url: '......./sap/ZNAV_SM6_SRV/Output',             success: function (data) {                       oModel.setData({                            modelData : data                             });               }           });                                this.getView().setModel(oModel);                                var oTable = new sap.ui.table.Table;                                oTable = this.byId("oTab");                                oTable.setModel(oModel);              },

 

View:-

var oTable = new sap.ui.table.Table({                        title: "Table Example",                  id: this.createId("oTab"),                        selectionMode: sap.ui.table.SelectionMode.Single,            columns: [                        new sap.ui.table.Column({                            label: new sap.ui.commons.Label({ text: "Field Label" }),                            template: new sap.ui.commons.TextView().bindProperty("text", "d/results/TrNo"),//                          sortProperty: "tr",                              width: "40px",                              hAlign: "Center"                        })                        ]            });
oTable.bindRows("/modelData");      //Bring the table onto the UI               oTable.placeAt("content");

 

HTML Page:

<!DOCTYPE HTML><html>       <head>              <meta http-equiv="X-UA-Compatible" content="IE=edge">                                   <script src="resources/sap-ui-core.js"                      id="sap-ui-bootstrap"                      data-sap-ui-libs="sap.ui.commons,sap.ui.core,sap.ui.ux3,sap.ui.table"                      data-sap-ui-theme="sap_goldreflection" >              </script>              <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->                                   <script>                                       sap.ui.localResources("otable");                     var view = sap.ui.view({id:"idoTable1", viewName:"otable.oTable", type:sap.ui.core.mvc.ViewType.JS});                                          view.placeAt("content");                                   </script>       </head>       <body class="sapUiBody" role="application">              <div id="content"></div>       </body></html>

 

 

Service response:

{  "d": {    "results": [      {        "__metadata": {          "uri": "....p/opu/odata/sap/ZNAV_SM6_SRV/Output('SAMPLE2')",          "type": "ZNAV_SM6_SRV.OUTPUT"        },        "TrSys": "AB",        "SrSys": "PQ",        "TrNo": "SAMPLE2"      },
...etc.

 

This application is not returning any data. This is working fine if I convert oModel to new sap.ui.model.odata.ODataModel, which means I have issue with JSON format only.

 

I received bunch of help on same topic but nothing is working for me.. I thought http://scn.sap.com/thread/3308554 solution works for me.. But not sure where I am doing wrong... still checking... want to see if I can get any help!

 

 

Thanks,

Naveen


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>