-2

I'm working on a SAPUI5 App containing a SplitApp with one MasterPage and many DeatilPages. I create a list of StandartListItems for the MasterPage, if I select one of them, I want to show the right DetailPage. But at this point I have no idea how to implement it.

Fill the list of the MasterPage:

var oMasterPage = sap.ui.getCore().byId("masterPage");
    var masterContentList = sap.ui.getCore().byId("masterList");

    masterContentList.bindItems({
        path : "/inhaltList",
        template : new sap.m.StandardListItem({
            title: "{master}"
        })
    });

And for each MasterListItem I create a DetailPage and add it to the SplitApp:

var detailContentList = new sap.m.List({});
         detailContentList.bindItems({
            path : "/inhaltList",
            sorter : new sap.ui.model.Sorter("name"),
            template : new sap.m.CustomListItem({
                content: [
                    new sap.m.VBox({
                        width : "80%",
                        displayInline : false,
                        direction: "Column",
                        items:[
                        new sap.ui.commons.TextView({text:"titel", design:sap.ui.commons.TextViewDesign.H2}),
                        //new sap.ui.commons.TextView({text:"{detail>titel}", design:sap.ui.commons.TextViewDesign.H2}),
                        //new sap.ui.commons.TextView({text:"{detail>content>text}", design:sap.ui.commons.TextViewDesign.Small})
                        new sap.ui.commons.TextView({text:"textetextetextetexttextexte", design:sap.ui.commons.TextViewDesign.Small})
                        ]
                    })
                ]
            })
        });

        var DetailPage = new sap.m.Page({
                    path : "/inhaltList",
                    title: "{master}",
                    content:[
                    detailContentList
                    ]
                });


        splitApp.addDetailPage(DetailPage);

In the end, I have one MasterPage in the SplitApp and in one case 4 DetailPages. That is up to this point working.

Now, I want to make a relation from the MasterListItem to the right DetailPage, so that the right DetailPage is showing up, if I selct the MasterListItem for that.

Does anyone have an idea?

Yvonne Marggraf
  • 368
  • 2
  • 5
  • 18
  • Please checkout the example Master-Detail application. There you should get some hints how this is working, especially with routing. https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/master-detail/webapp/test/mockServer.html – matbtt Nov 16 '16 at 19:50
  • I know this example already and it have nothing to do with my situation. IT IS STATIC! BUT: I'm going to do it dynamically!! – Yvonne Marggraf Nov 17 '16 at 08:04
  • You did not mention that you need a dynamic approach. Quote from your questions: [...] if I select one of them, I want to show the right DetailPage [...]. However you can wire Master and Detail together using routing. The Detail could be an empty view whose controller loads the dedicated view as subview. – matbtt Nov 17 '16 at 08:47

1 Answers1

0

As I understand you have sap.m.StandardListItem with some items and you want to switch details while clicking on an item. Easiest way: 1. add press event to your item. controller is a controller, if you are doing it in a view.

press: [controller.pressItem, controller]

2.from pressItem, get your application and use to method.

var app = sap.ui.getCore().byId("splitApp");
app.to(id, "slide", data)

where id - is the id of your detail page and data is the payload you want to send to the page.

Notes: 1. Implementation through event bus will also work and would be better

Shidai
  • 219
  • 1
  • 8
  • The Problem is, that I'm generate the DetailPages aotomatically and depending on the selcted data-packed in the Controller of the MasterPage. For each MasterListElement I create a Detailpage and add it right there to the SplitApp.... So, it's nocht posible to ask for an id, because if I'm going to set one, the console tells me, that the id is dublicated. – Yvonne Marggraf Nov 16 '16 at 15:36