[英]SAPUI5 - How to set a link a MasterDetail Split App
I'm working on a SAPUI5 App containing a SplitApp with one MasterPage and many DeatilPages.我正在开发一个 SAPUI5 应用程序,其中包含一个带有一个 MasterPage 和许多 DeatilPages 的 SplitApp。 I create a list of StandartListItems for the MasterPage, if I select one of them, I want to show the right DetailPage.
我为 MasterPage 创建了一个 StandartListItems 列表,如果我选择其中之一,我想显示正确的 DetailPage。 But at this point I have no idea how to implement it.
但此时我不知道如何实现它。
Fill the list of the MasterPage:填写 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:对于每个 MasterListItem,我创建一个 DetailPage 并将其添加到 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.最后,我在 SplitApp 中有一个 MasterPage,在一种情况下有 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.现在,我想建立从 MasterListItem 到正确的 DetailPage 的关系,以便显示正确的 DetailPage,如果我为此选择 MasterListItem。
Does anyone have an idea?有没有人有想法?
As I understand you have sap.m.StandardListItem with some items and you want to switch details while clicking on an item.据我了解,您有一些项目的 sap.m.StandardListItem,并且您想在单击项目时切换详细信息。 Easiest way: 1. add press event to your item.
最简单的方法: 1. 向您的项目添加新闻事件。 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. 2.从pressItem,获取您的应用程序并使用to方法。
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.其中 id - 是您的详细信息页面的 id,而 data 是您要发送到该页面的有效负载。
Notes: 1. Implementation through event bus will also work and would be better注意事项: 1.通过事件总线实现也可以,而且会更好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.