Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8392

Issue while accessing Northwind Service

$
0
0

Hello All,

 

I very familiar question for you. I am trying to access Northwind service and populate customers and orders table. I have proxy configured and can access the service without any error. However, the issue comes when Customers entity is accessed. The code is as follows.

 

Code under CREATECONTENT

 

var aControls = [];

      

   var url = "proxy/http/services.odata.org/Northwind/Northwind.svc/";

   var oModel = new sap.ui.model.odata.ODataModel(url, false);

  

   sap.ui.getCore().setModel(oModel);

  

   //---- CUSTOMER TABLE

   var customerTable = new sap.ui.table.Table({

    title: "Customers",

    visibleRowCount: 7,

    selectionMode: sap.ui.table.SelectionMode.Single

   });

 

 

  //---- CUSTOMER TABLE COLUMNS

  

   customerTable.addColumn(new sap.ui.table.Column

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

    template: new sap.ui.commons.TextView({text: "{CustomerID}"})})); 

 

 

   //---- ORDER TABLE

   var orderTable = new sap.ui.table.Table({

    title: "Orders",

    visibleRowCount: 5,

    selectionMode: sap.ui.table.SelectionMode.None

   }); 

 

 

  //---- ORDER TABLE COLUMNS     

   var orderTableColumns = [

                            {text: "Order ID", property: "OrderID"},

                           {text: "Order Date", property: "OrderDate"},

                           {text: "Required Date", property: "RequiredDate"},

                           {text: "Shipped Date", property: "ShippedDate"}

                           ];

           orderTableColumns.forEach(function(column){

               orderTable.addColumn(new sap.ui.table.Column({

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

                  template: new sap.ui.commons.TextView().bindProperty("text", column.property),

                  sortProperty: column.property,

                  filterProperty: column.property,

                  width: "75px",

                  hAlign: "Center"

                 }));     

           });     

 

 

     //Create a model and bind the table rows to this model

   customerTable.setModel(oModel);

   customerTable.bindRows("/Customers"); // Fill customer table with customer records

   orderTable.setModel(oModel);

 

 

   // Handle row selection event

   customerTable.attachRowSelectionChange(function (event) {

   // Select orders for the selected customer

   // (using Odata navigation defined in metadata for Customers)

   var selectedRowContext = event.getParameter("rowContext");

   var selectedOrders = selectedRowContext + "/Orders";

   orderTable.bindRows("/" + selectedOrders);

   });

 

 

   // Return controls in this view

      aControls.push(customerTable);

      aControls.push(orderTable);

      return aControls;

 

END CODE

 

I am attaching the error screen shot to give you a clear idea. I searched a lot but failed to find a solution and reason for this issue. I had COR resolved by reverse proxy.

 

I hope someone can help me out with this, despite being a so much discussed issue.

 

Regards

Abhi


Viewing all articles
Browse latest Browse all 8392

Latest Images

Trending Articles



Latest Images

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