UI5 – Connecting Master to Detail

Home / Blog / UI5 – Connecting Master to Detail

Well, I wish I could say this was an easy thing I finally figured out…  but it was a hard fought victory 🙂  I spent more hours than I care to admit fighting through this.  My issue that I had a list pulled from gateway service.  The problem was that when I would click on an entry in the list, the values were not being populated.  Of course, I tried to extend what I learned, and that got me into trouble.  But like everything, I found my home 🙂

Let’s start at the beginning.  First, I used the following tutorial as my baseline.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/8022ac87-1f60-3110-5383-fa68a91d7f8b?overridelayout=true&59017145622993

This was great, but it was using static data.  I had services built for my iOS apps, so I decided to start by calling one of those.  It was good.  I was able to build the list, but try as I might, I just couldn’t get the data into the detail screen.

Here’s what I finally figured out.

component.js

oView.setModel(oModel, “orders”);

this was a switch from the tutorial, where the model didn’t get a name.  I thought this would make no difference.  Boy was I mistaken.  Here’s what I needed to do  to finish this change

app.controller.js

page.setBindingContext(context, “orders”);

here, I didn’t realize I could add a 2nd parameter.  I needed to add my model name.

master.controller.js

handleListItemPress : function (evt) {
var context = evt.getSource().getBindingContext(“orders”);
this.nav.to(“Detail”, context);
},

handleListSelect : function (evt) {
var context = evt.getParameter(“listItem”).getBindingContext(“orders”);
this.nav.to(“Detail”, context);
},

the getBindingContext() needed to list the name “orders”.

Detail.view.xml

<ObjectHeader
title=”{orders>DocNum}” >

make sure when you enter the variable, that {orders>DocNum}

special thanks to the following post that gave me the final piece (that app.controller.js)

http://scn.sap.com/thread/3785577

Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *