cancel
Showing results for 
Search instead for 
Did you mean: 

Split app Master Detail

Former Member

Hello Everyone ,

i am making an master detail split app , i am accesing data from odata model es5 , i had maked my master page , now i want when i click on object list item in master i get the detail of that product in detail view , what code i have to do in detail page now

My code is Below

Master view

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="Master.Master.controller.Master"
	xmlns:html="http://www.w3.org/1999/xhtml">
	<App>
		<pages>
			<Page title="Product List">
				<content>
					<List id="productList" headerText="Products" items="{/ProductSet}">
						<headerToolbar>
							<Toolbar>
								<SearchField width="100%" search="onFilterProduct"/>
							</Toolbar>
						</headerToolbar>
						<items>
							<ObjectListItem title="{Name}" intro="{ProductID}" number="{Price}" type="Active" numberUnit="{CurrencyCode}" press="handleListItemPress"></ObjectListItem>
						</items>
					</List>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View>

Master controller

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/model/Filter",
	"sap/ui/model/FilterOperator"
], function (Controller, Filter, FilterOperator) {
	"use strict";


	return Controller.extend("Master.Master.controller.Master", {


		onFilterProduct: function (oEvent) {


			var aFilter = [],
				sQuery = oEvent.getParameter("query"),
				oList = this.getView().byId("productList"),
				oBinding = oList.getBinding("items");


			if (sQuery) {


				aFilter.push(new Filter("ProductID", FilterOperator.Contains, sQuery));


			}
			oBinding.filter(aFilter);
		},


		handleListItemPress: function (evt) {
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			var selectedProductId = evt.getSource().getBindingContext().getProperty("ProductID");
			oRouter.navTo("Detail", {
				productId: selectedProductId
			});
		}



menifest.json

	"routes": [
				{
					"pattern": "",
					"name": "app",
					"viewName": "app",
					"targetControl": "idApp",
					"subroutes": [
						{
							"pattern": "",
							"name": "Master",
							"viewName": "Master",
							"targetControl": "idsplit",
							"targetAggregation": "masterPages",
							"subroutes":[{
								
								"pattern":"Detail/{ProductID}",
								"name":"Detail",
								"viewName":"Detail",
								"targetAggregation":"detailPages"
								
							}]
						}
					]

Accepted Solutions (0)

Answers (2)

Answers (2)

jorge_cabanas
Participant

Why create two questions with the same problem and topic?
Patience is a virtue, don't overload the community 😉

https://answers.sap.com/questions/682654/not-able-to-get-the-data-in-detail-view.htm

maheshpalavalli
Active Contributor
0 Kudos

Hi Mayur,

You need to read the product ID from the routing and do a bind element for the detail page for the product detail entity to show the product detail.

For reading the routing parameter in the detail page:

https://ui5.sap.com/#/topic/2366345a94f64ec1a80f9d9ce50a59ef

For doing the bind element(Not required but highly recommended):

https://ui5.sap.com/#/topic/6c7c5c266b534e7ea9a28f861dc515f5

I can understand you are a beginner to UI5, so I highly recommend you to use the WebIDE which has the Master-Detail page template, by using this you can generate a basic a application with all bindings done to Master and Detail page. Then you can see the code that the template is having and enhance on that for your specific requirement.

How to use Template:

https://openui5.hana.ondemand.com/1.36.5/docs/guide/0c5dc937271f4f56b5e7d54676199860.html

Also, the routing you are using is very old, you need to use routes & targets based new routing. So it would be better to generate the app using a template.

BR,
Mahesh

Former Member
0 Kudos

Hello Sir ,

Thanks for your reply , I will read this .

BR,

Mayur Sharma

Former Member
0 Kudos

How to use new Routing sir ?

any article of that then Please share.

Thanks and Regards:

Mayur Sharma

maheshpalavalli
Active Contributor
0 Kudos

New Routing uses Target based routing.. You can go and do the developer tutorials in SAP UI5:

https://ui5.sap.com/#/topic/1b6dcd39a6a74f528b27ddb22f15af0d

Thats why I am suggesting you to create an UI5 application using the master -detail template from webide which will automatically creates the routing for you.

BR,

Mahesh

Former Member
0 Kudos

Hello Sir ,

Now my detail view is getting open , but data is not getting bind to that .

Regards:-

Mayur Sharma

maheshpalavalli
Active Contributor
0 Kudos

Hi mayur sharma,

If you generate using master-detail template, by default the binding is applied in detail page and it works.. Any reason why it is not working(errors, console log?)

BR,

Mahesh