cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the Expand parameters from Master to Detail page?

Former Member
0 Kudos

Hello All,

I face an issue with one of the Master-Detail app developed using the oData services.

Master view list items are binded with "/Products" with Expand to navigation properties "toSupplier,toContent".

Now, using the router mechanism I have passed the path of the selected product via Parameter to detail view. Read the path in the detail view controller and bound the Object Header with this path to display the same details. I have few tabs under the Object header displaying Supplier and Content Details. Under these tabs while I refer to the relevant fields as "{toSupplier/SupplierID}" or "{toConent/ContentID}" is not displaying any data.

As per my understanding, I noticed the oData available in the Master View, but the same is not available in Detail view.

Can you please suggest on how to get the data binding with expand parameters available to detial view?

Cheers

Sunil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Jun Wu,

Here is the code snippet

Master View :-

<List id="slist" items="{ path: '/shopping_cartSet', parameters: { expand: 'ToVendor,sc_to_tech_specs,sc_to_contents' } }" >

<StandardListItem title="{Zpname}" description="{Zcategory}" type="Active" press="onPress"></StandardListItem>

</List>

Master Controller:-

onPress: function (oEvent){

var oSource = oEvent.getSource(); var oContext = oSource.getBindingContext().getPath();

var oRouter = sap.ui.core.UIComponent.getRouterFor(this); var oModel = this.getView().getModel();

oRouter.navTo( "object", {Path : oContext.substring(1)}); }

Detail View:-

<IconTabBar id="TabBar">

<items>

<IconTabFilter text="Tech.Specs" id="Tech">

<l:VerticalLayout> <Label text="Model"/> <Text text="{sc_to_tech_specs/Zmodel}"/> <Label text="Make"/> <Text text="{sc_to_tech_specs/Zmake}"/> </l:VerticalLayout>

</IconTabFilter>

<IconTabFilter text="Contents"> <l:VerticalLayout> <Label text="Model"/> <Text text="{sc_to_contents/Zmodel}"/> <Label text="Make"/> <Text text="{sc_to_contents/Zmake}"/> </l:VerticalLayout>

</IconTabFilter>/

<IconTabBar>

Detail Controller:-

_onObjectMatched: function(oEvent){

var oPath = oEvent.getParameters().arguments.Path; var oContext = oEvent.getSource().oBindingContexts; var oBject = this.getView().byId("OBH"); var oTab = this.getView().byId("Tech"); oBject.bindContext("/" + oPath); oTab.bindContext("/" + oPath); }

Routes:-

{ "pattern": "Objects/{Path}", "name": "object", "target": ["master", "object"] }

Target:-

"object": { "viewName": "Detail", "viewId": "detail", "viewLevel": 2 },

Hope these snippets provide you a good information.

Cheers,

Sunil

junwu
Active Contributor
0 Kudos

code please

Former Member
0 Kudos

Hello Jun Wu,

Here is the code snippet

Master View :-

<List id="slist" items="{ path: '/shopping_cartSet', parameters: { expand: 'ToVendor,sc_to_tech_specs,sc_to_contents' } }" >

<StandardListItem title="{Zpname}" description="{Zcategory}" type="Active" press="onPress"></StandardListItem>

</List>

Master Controller:-

onPress: function (oEvent){

var oSource = oEvent.getSource(); var oContext = oSource.getBindingContext().getPath();

var oRouter = sap.ui.core.UIComponent.getRouterFor(this); var oModel = this.getView().getModel();

oRouter.navTo( "object", {Path : oContext.substring(1)}); }

Detail View:-

<IconTabBar id="TabBar">

<items>

<IconTabFilter text="Tech.Specs" id="Tech">

<l:VerticalLayout> <Label text="Model"/> <Text text="{sc_to_tech_specs/Zmodel}"/> <Label text="Make"/> <Text text="{sc_to_tech_specs/Zmake}"/> </l:VerticalLayout>

</IconTabFilter>

<IconTabFilter text="Contents"> <l:VerticalLayout> <Label text="Model"/> <Text text="{sc_to_contents/Zmodel}"/> <Label text="Make"/> <Text text="{sc_to_contents/Zmake}"/> </l:VerticalLayout>

</IconTabFilter>/

<IconTabBar>

Detail Controller:-

_onObjectMatched: function(oEvent){

var oPath = oEvent.getParameters().arguments.Path; var oContext = oEvent.getSource().oBindingContexts; var oBject = this.getView().byId("OBH"); var oTab = this.getView().byId("Tech"); oBject.bindContext("/" + oPath); oTab.bindContext("/" + oPath); }

Routes:-

{ "pattern": "Objects/{Path}", "name": "object", "target": ["master", "object"] }

Target:-

"object": { "viewName": "Detail", "viewId": "detail", "viewLevel": 2 },

Hope these snippets provide you a good information.

Cheers,

Sunil

Former Member
0 Kudos

Closing this question as the issue is with the oData service and not the UI5 controls.

Appreciate your help 🙂