【发布时间】:2017-04-04 17:23:26
【问题描述】:
我正在开发一个 SAPUI5 应用程序,使用 sap.m.splitapp 在 MasterDetailView 中显示一些数据。我的问题是退出等于问题Master menu is not visible on mobile devices but is visible on tablet。
在我的情况下,我将根据请求的数据创建一个带有 MasterController 的 MasterPage。根据这些数据,我在 MasterController 的函数中动态创建 DetailPages。
for(var i=0;i<adata.inhaltList.length;i++){var DetailPage = new sap.m.Page({
title: masterString,
showNavButton: true,
navButtonPress:function () {
var oSplitApp = this.getView().getParent().getParent();
var oMaster = oSplitApp.getMasterPages()[0];
oSplitApp.toMaster(oMaster, "flip");
}
}); };
在我的测试设备上,一切正常,除了我无法显示 MasterPage,甚至没有显示按钮。
我已经尝试了链接问题的解决方案,但我收到错误:“对象元素 sap.m.Page#__page0 没有方法 'getView'”。所以它没有用。 即使是自己动手的解决方案,在自定义标题中添加一个按钮:
contentLeft: [new sap.m.Button({
icon: "sap-icon://paging",
press: function() {
var splitApp = sap.ui.getCore().byId("ContentApp");
if (splitApp.isMasterShown()) {
console.log("Master weg");
splitApp.hideMaster();
} else {
console.log("Master kommt");
splitApp.showMaster();
var oSplitApp = this.getView().getParent().getParent();
var oMaster = oSplitApp.getMasterPages()[0];
oSplitApp.toMaster(oMaster, "flip");
};
}
})]
并试图手动显示大师没有工作。
SAPUI5 函数:oSplitApp.showMaster();在资源管理器中工作正常,但在设备上不行!有人知道为什么吗?并且可能有解决方案?
【问题讨论】:
-
您已经拥有 splitApp (
sap.ui.getCore().byId("ContentApp");),然后您再次获取 splitApp (this.getView().getParent().getParent();)。如果第二个对象不起作用,只需重用您的第一个对象。此外,您是通过 JS 而不是 XML 创建视图,这就是复制粘贴我的代码不起作用的原因。我的代码旨在在控制器中运行,而不是直接在视图中运行。尝试将视图与实际逻辑分开。 -
在这种情况下也是:“未捕获的 TypeError:this.getView 不是函数”。所以它不依赖于在主控制器中创建 DetailView
标签: master-pages master-detail sapui5