Skip to Content
0

$expand Aggregation Binding Problem

Mar 14 at 12:51 AM

29

avatar image

Hello Everyone,

It has been a while since I posted, but this one's got me scratching my head. I'm trying to navigate from a Master.view.xml to a Detail.view.xml. Pretty straightforward so far. However, on one of the panels of the detail.view.xml I want to get data from a navigation property so I'm trying a $expand. I'm not getting any results and am at an impasse.

I'm using the standard CRM CRM_OPPORTUNITY_SRV service.

Here is my detail.view.xml. The second panel with id=_panel1 doesn't work. The third panel is just blank right now.

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml"
	controllerName="MyOpportunities.controller.Detail">
	<App>
		<pages>
			<Page title="{ProspectName}" showNavButton="true" navButtonPress="GoToMaster">
				<content>
					<Panel id="__panel0" expandable="true" expanded="true">
						<headerToolbar>
							<Toolbar height="3rem">
								<Text text="Info"/>
								<ToolbarSpacer/>
								<Button icon="sap-icon://edit"/>
							</Toolbar>
						</headerToolbar>
						<content>
							<List >
								<DisplayListItem label="Opportunity Group" value="{ZTypeText}"/>
								<DisplayListItem label="Source" value="{ZSourceText}"/>
								<DisplayListItem label="Closing Date" value="{ path: 'ClosingDate', type: 'sap.ui.model.type.Date', formatOptions: { style: 'long'}}"/>
								<DisplayListItem label="Status" value="{UserStatusText}"/>
								<DisplayListItem label="Probability" value="{ChanceOfSuccess}"/>
								<DisplayListItem label="Priority" value="{PriorityCode}"/>
								<DisplayListItem label="Exp Sales Volume" value="{ExpectedSalesVolume}"/>
								<DisplayListItem label="Exp Total Volume" value="{TotalExpectedNetValue}"/>
							</List>
						</content>
					</Panel>
					<Panel id="__panel1" expandable="true" expanded="false">
						<headerToolbar>
							<Toolbar height="3rem">
								<Text text="Notes - {Guid}"/>
							</Toolbar>
						</headerToolbar>
						<content>
							<List id="notes" items="{ path: '', parameters: { 'expand' : 'ComplexNotes' } }">
								<items> 
									<ObjectListItem title="Anything" intro="AtAll"/>
									<ObjectListItem title="{Creator}"/>
									<ObjectListItem title="{Content}"/>
								</items>
							</List>
						</content>
					</Panel>
					<Panel id="__panel2" expandable="true" expanded="false">
						<headerToolbar>
							<Toolbar height="3rem">
								<Text text="Contacts"/>
							</Toolbar>
						</headerToolbar>
						<content>
							<DisplayListItem label="{MainContactName}" value="{Description}"/>
						</content>
					</Panel>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View>

Here is my detail.controller.js. Nothing special here, but just in case.

sap.ui.define(["sap/ui/core/mvc/Controller"], function(Controller) {
	"use strict";
	return Controller.extend("MyOpportunities.controller.Detail", {


		onInit: function() {
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			oRouter.getRoute("r_detail").attachMatched(this._onRouteFound, this);
			
		},
		_onRouteFound: function(oEvent) {
				var oArg = oEvent.getParameter("arguments");
				var oView = this.getView();
				oView.bindElement({
					path: "/Opportunities(guid'" + oArg.Guid + "')"
				});
			},
		GoToMaster: function(oEvent) {
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			oRouter.navTo("r_master");
		}
	});
});

I would appreciate any advice on what I may be doing wrong here. Truly appreciate it. I spent the past half day on this and I'm running in circles.

Let me know if posting more detail will help.

Thanks,
Greg

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Greg Foss Mar 20 at 05:19 PM
0

Well, I never was able to make it work by modifying the view. However, I did just modify the controller that called the view to have the $expand in it. I did it like this:

_onRouteFound: function(oEvent) {
	var oArg = oEvent.getParameter("arguments");
	var oView = this.getView();
	oView.bindElement({
		path: "/Opportunities(guid'" + oArg.Guid + "')", 
		parameters: {"expand":"ComplexNotes,SalesTeam,MainContact"}
});
Share
10 |10000 characters needed characters left characters exceeded