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

Unable to display the data in table using the ODTA service in SAP UI5

$
0
0

Hi

 

I am new to SAP UI5. I am trying to build one application using sap ui5 for displaying data in table using the ODATA service. But i am getting the following error. When i test the ODATA service using REST tool, I am getting the data with out any issue.

But when tried from application , i am getting the following error. Please provide the help.

 

Server Error: HTTP request Failed

 

I have few questions related the following code.

 

1) Construction ODATA service string is correct while passing the parameters

2) What is name need to be given while binding the data rows.  On what basis , name need to be given? Please clarify it.

 

which of the following binding is correct

oTable.bindRows("entry");

oTable.bindRows("BusinessPartnerCollection");


 


 

Here is the JS view code:

 

sap.ui.jsview("customerlistusingxml.CustomerList", {

 

 

      getControllerName : function() {

         return "customerlistusingxml.CustomerList";

      },

 

 

      createContent : function(oController) {

                // we will create our own user interface

                /*First of all we create a matrix layout, a panel ( something like the tray bar in WDA just to make it clear  )

                 * and we associate a panel title, this panel will contain the table list of all the Customers exposed by our Gateway service

                 *

                 */

               

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

                layout.setWidth("80%");

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

               

                var rTitle = new sap.ui.commons.Title('rTitle');    

                rTitle.setText('All - Customers');    

                rPannel.setTitle(rTitle); 

                alert('Before table');

                /*First of all we create a matrix layout, a panel ( something like the tray bar in WDA just to make it clear  )

                 * and we associate a panel title, this panel will contain the table list of all the fights

                 * exposed by our Gateway service.

                 *

                 */

                var oTable = new sap.ui.table.DataTable();

                                    oTable.addColumn( 

                                       new sap.ui.table.Column({ 

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

                                            template: new sap.ui.commons.TextField().bindProperty("value", "BusinessPartnerID"), 

                                            sortProperty: "BusinessPartnerID" 

                                  })); 

                                   

                                  oTable.addColumn( 

                                       new sap.ui.table.Column({ 

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

                                            template: new sap.ui.commons.TextField().bindProperty("value", "Company"), 

                                            sortProperty: "Company" 

                                  })); 

                                   

                                  oTable.addColumn( 

                                       new sap.ui.table.Column({ 

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

                                            template: new sap.ui.commons.TextField().bindProperty("value", "BusinessPartnerRoleText"), 

                                            sortProperty: "BusinessPartnerRoleText" 

                                  })); 

                                  oTable.addColumn( 

                                          new sap.ui.table.Column({ 

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

                                               template: new sap.ui.commons.TextField().bindProperty("value", "CurrencyText"), 

                                               sortProperty: "CurrencyText" 

                                     })); 

 

 

                                  alert('before model');

                                   

           

                                  var oModel = new sap.ui.model.odata.ODataModel("https://sapes1.sapdevcenter.com/sap/opu/odata/IWBEP/GWDEMO/BusinessPartnerCollection");

   

                

            

                            oModel.attachRequestFailed(function(evt) {

                                                  alert("Server error: " + evt.getParameter("message") + " - " + evt.getParameter("statusText"));

                                        });

 

                                  oTable.setModel(oModel); 

                                  oTable.bindRows("/entry"); 

                                  

                                  //We are almost done, we only need to attach our table to the panel

                                  rPannel.addContent(oTable);   

                                  layout.createRow(rPannel); 

                                   

                                  this.addContent(layout);

                        

      }

 

 

});


Viewing all articles
Browse latest Browse all 6178

Trending Articles



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