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

how to bind different entity

$
0
0

Hi

 

I am using Northwind service and have created a table mapped to Entity - Employees. Now on row selection I want to show details from other entity(lets say Territories) in a form below the table.I read about expand parameter but not sure how to use it.

 

Here is my code:

 

Component.js

createContent : function() {

 

var oModel = new sap.ui.model.odata.v2.ODataModel(

  "proxy/http/services.odata.org/V3/Northwind/Northwind.svc");

 

  var app = new sap.m.App("app1",{initialPage:"idFirstView"});

 

  var page = sap.ui.view({id:"idFirstView", viewName:"finalcomponent.finalcomponent.View1", type:sap.ui.core.mvc.ViewType.XML});

  var page1 = sap.ui.view({id:"idSecondView", viewName:"finalcomponent.finalcomponent.View2", type:sap.ui.core.mvc.ViewType.XML});

 

  app.addPage(page).addPage(page1);

 

  app.setModel(oModel,"emp");

 

 

  return app;

  }

 

on table row selection inside controller

 

onhandleSelectionChange: function(evt)

  {

  app = sap.ui.getCore().byId("app1");

 

  var tbl = this.getView().byId("idEmp");

  var oselectedItem = tbl.getSelectedItem();

  var aggregations = tbl.getAggregation("items");

  var index = aggregations.indexOf(oselectedItem);

 

  if (index == -1) {

  alert("Please select a row first");

  } else {

  var tblmodel = tbl.getModel("emp");

  var data = tblmodel.oData['Employees(' + index + ')'];

  console.log(data);                                                            // This gives me current data. How to get from Terrirtories

  }

 

app.to("idSecondView");

 

 

  },


Viewing all articles
Browse latest Browse all 845

Trending Articles