Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3218

not getting data in detail page of splitapp

$
0
0

hi experts,

am not getting data in detail page of splitapp, am using json model.

 

Component.js


sap.ui.core.UIComponent.extend("madhu.Component",{

  metadata  : {

        manifest: "json"

    },

  init : function(){

  var oModel = new sap.ui.model.json.JSONModel("model/data.json");

  this.setModel(oModel);

  sap.ui.core.UIComponent.prototype.init.apply(this);

  var oRouter = this.getRouter();

  oRouter.initialize();

 

  }

});

 


manifest.json

{

  "sap.app": {

  "id": "madhu",

  "type": "application"

  },

  "sap.ui": {

  "deviceTypes": {

  "desktop": true,

  "tablet": true,

  "phone": true

  },

  "supportedThemes": [

  "sap_bluecrystal"

  ]

  },

  "sap.ui5": {

  "_version": "1.1.0",

  "rootView": "madhu.views.App",

  "id": "idApp",

  "dependencies": {

  "minUI5Version": "1.30",

  "libs": {

  "sap.m": {

 

 

  }

  }

  },

  "routing": {

  "config": {

  "routerClass": "sap.m.routing.Router",

  "viewType": "XML",

  "viewPath": "madhu.views",

  "controlId": "idSplitApp"

  },

  "routes": [{

  "pattern": "",

  "name": "product",

  "target": [

  "master",

  "detail"

  ]

 

 

  }, {

  "pattern": "Products/{Manufacturer}",

  "name": "Detail",

  "target": [

  "master",

  "detail"

  ]

  }],

  "targets": {

  "master": {

  "viewName": "Master",

  "controlAggregation": "masterPages"

  },

  "detail": {

  "viewName": "Detail",

  "controlAggregation": "detailPages"

  }

  }

 

 

  }

  }

}

 

 

Master View

 

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m" controllerName="madhu.views.Master" xmlns:html="http://www.w3.org/1999/xhtml">

  <Page title="Products">

  <subHeader>

  <Toolbar>

  <SearchField width="100%" liveChange="onSearch" />

  </Toolbar>

  </subHeader>

  <List id="idProdList" items="{/Item}">

  <StandardListItem title="{Manufacturer}"

  description="{ProductID}" iconDensityAware="false" iconInset="false"

  type="Navigation" press="onListItemPressed" />

  </List>

  </Page>

</core:View>

 

 

Master Controller

 

onInit : function() {

  oRouter = this.getOwnerComponent().getRouter();

 

 

  var oList = this.getView().byId("idProdList");

 

 

  oList.attachUpdateFinished(function() {

  var items = oList.getItems();

  // debugger;

  oList.setSelectedItem(items[0]);

 

 

  var ManufacturerVal = items[0].getBindingContext().getProperty(

  "Manufacturer");

  oRouter.navTo("Detail", {

  Manufacturer : ManufacturerVal

  }, true);

  })

  },

 

 

  onListItemPressed : function(oEvent) {

  var oRouter = this.getOwnerComponent().getRouter();

  var ManufacturerVal = oEvent.getSource().getBindingContext()

  .getProperty("Manufacturer");

  oRouter.navTo("Detail", {

  Manufacturer : ManufacturerVal

  });

 

 

  },

  onSearch : function(oEvent) {

  var filters = [];

  var query = oEvent.getSource().getValue();

  if (query && query.length > 0) {

  // debugger;

  var oFilter = new sap.ui.model.Filter("Manufacturer",

  sap.ui.model.FilterOperator.Contains, query);

  filters.push(oFilter);

  var oList = this.getView().byId("idProdList");

  var binding = oList.getBinding("items");

  binding.filter(filters);

  }else {

  return false;

  }

  }

 

 

Detail View

 

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m" controllerName="madhu.views.Detail" xmlns:html="http://www.w3.org/1999/xhtml">

  <Page title="Product Details">

  <content>

  <ObjectHeader id="objectHeader" title="{Manufacturer}"

  number="{ProductID}" />

  <IconTabBar>

  <items>

IconTabFilter icon="sap-icon://attachment" text="Product Details">

  <ObjectHeader title="{Price}" />

  </IconTabFilter>

  </items>

  </IconTabBar>

  </content>

  <footer>

  </footer>

  </Page>

</core:View>

 

 

Detail Controller

 

sap.ui.controller(

  "madhu.views.Detail",

  {

 

 

  onInit : function() {

  var dataObject = [ {} ];

  var oModelData = new sap.ui.model.json.JSONModel();

  oModelData.setData(dataObject);

  this.getView().setModel(oModelData);

  oRouter = sap.ui.core.UIComponent.getRouterFor(this);

  oRouter.attachRoutePatternMatched(

  this.handleRouteMatched, this);

 

 

  },

  handleRouteMatched : function(oEvent) {

  var ManufacturerVal = oEvent.getParameter("arguments").Manufacturer;

  this.getView().bindElement(

  "/Item('" + ManufacturerVal + "')");

  },

 

 

model/data.json

 

{

  "Item": [{

  "ProductID": "0001",

  "Manufacturer": "Microsoft",

  "Type": "Optical Mouse",

  "Price": 300

  }, {

  "ProductID": "0002",

  "Manufacturer": "Intex",

  "Type": "Laptop Mouse",

  "Price": 200

  }, {

  "ProductID": "0003",

  "Manufacturer": "Iball",

  "Type": "Traditional Mouse",

  "Price": 150

  }, {

  "ProductID": "0004",

  "Manufacturer": "Dell",

  "Type": "Gaming Mouse",

  "Price": 400

  }, {

  "ProductID": "0005",

  "Manufacturer": "Logitech",

  "Type": "Wireless mouse",

  "Price": 500

  }, {

  "ProductID": "0006",

  "Manufacturer": "HP",

  "Type": "Optical Mouse",

  "Price": 300

  }

]

}

 

Untitled.png

 

Please help

Thanks in Advance


Viewing all articles
Browse latest Browse all 3218

Trending Articles



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