一种简单地实现 SAP UI5 Master detail 页面的方法

简介: 一种简单地实现 SAP UI5 Master detail 页面的方法

实现效果如下图所示:

image.png


app view 的实现代码:

// @ts-nocheck
sap.ui.jsview("jerrylist.view.App", {
  getControllerName: function () {
  return "jerrylist.view.App";
  },
  createContent: function (oController) {
  // to avoid scroll bars on desktop the root view must be set to block display
  this.setDisplayBlock(true);
  this.app = new sap.m.SplitApp();
  // load the master page
  var master = sap.ui.xmlview("Master", "jerrylist.view.Master");
  master.getController().nav = this.getController();
  this.app.addPage(master, true);
  // load the empty page
  var empty = sap.ui.xmlview("Empty", "jerrylist.view.Empty");
  this.app.addPage(empty, false);
  return this.app;
  }
});

代码第 13 行创建的 sap.m.SplitApp, 实际上是 SplitContainer:

image.png



这个 addPage 方法内部,分别调用 addMasterPage 或者 addDetailPage:


image.png

此时 detail 页面是空的:

image.png


Master List 点击事件,注册在 Master.view.xml 里:handleListSelect


image.png


点击之后,从 event 事件对象里,获得 binding context:


image.png


通过 path 能拿到具体的模型数据:


image.png


使用 this.nav.to(“Detail”, context) 跳转到 detail 页面:


image.png


Master view controller 的 nav 属性,在 View controller 里被赋值:


image.png


在 to 实现里:动态创建一个新的 id 为 Detail 的视图,然后调用 splitContainer.addPage, 将其加到 Split App 里:

image.png



调用 app.to 方法,显示页面:

image.png


SplitApp to 方法的注释:

image.png

/**
  * Navigates to the given page inside the SplitContainer.
  * The navigation is done inside the master area if the page has been added,
  * otherwise, it tries to do the page navigation in the detail area.
  *
  * @param {string} sPageId
  *         The screen to which we are navigating to. The ID or the control itself can be given.
     * @param {string} [transitionName=slide]
     *         The type of the transition/animation to apply. Options are "slide" (horizontal movement from the right), "baseSlide", "fade", "flip", and "show"
  *         and the names of any registered custom transitions.
  *
  *         None of the standard transitions is currently making use of any given transition parameters.
  * @param {object} oData
  *         This optional object can carry any payload data which should be made available to the target page. The BeforeShow event on the target page will contain this data object as data property.
  *
  *         Use case: in scenarios where the entity triggering the navigation can or should not directly initialize the target page, it can fill this object and the target page itself (or a listener on it) can take over the initialization, using the given data.
  *
  *         When the transitionParameters object is used, this "data" object must also be given (either as object or as null) in order to have a proper parameter order.
  * @param {object} oTransitionParameters
  *         This optional object can contain additional information for the transition function, like the DOM element which triggered the transition or the desired transition duration.
  *
  *         For a proper parameter order, the "data" parameter must be given when the transitionParameters parameter is used (it can be given as "null").
  *
  *         NOTE: It depends on the transition function how the object should be structured and which parameters are actually used to influence the transition.
  *         The "show", "slide" and "fade" transitions do not use any parameter.
  * @type this
  * @public
  * @since 1.10.0
  * @ui5-metamodel This method also will be described in the UI5 (legacy) designtime metamodel
  */



相关文章
|
19天前
|
人工智能 搜索推荐 Serverless
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
41 7
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
|
19天前
|
JavaScript 前端开发
如何优雅的只在当前页面中覆盖ui库中组件的样式(vue的问题)
如何优雅的只在当前页面中覆盖ui库中组件的样式(vue的问题)
14 0
如何优雅的只在当前页面中覆盖ui库中组件的样式(vue的问题)
|
29天前
|
机器学习/深度学习 人工智能 前端开发
机器学习PAI常见问题之web ui 项目启动后页面打不开如何解决
PAI(平台为智能,Platform for Artificial Intelligence)是阿里云提供的一个全面的人工智能开发平台,旨在为开发者提供机器学习、深度学习等人工智能技术的模型训练、优化和部署服务。以下是PAI平台使用中的一些常见问题及其答案汇总,帮助用户解决在使用过程中遇到的问题。
|
1月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
27 0
|
1月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
15 0
|
1月前
|
Web App开发 数据采集 前端开发
纯技术讨论:如何让 SAP UI5 应用无法被别人在浏览器里调试 - 这种做法不推荐试读版
纯技术讨论:如何让 SAP UI5 应用无法被别人在浏览器里调试 - 这种做法不推荐试读版
15 0
|
1月前
|
XML 存储 数据格式
SAP UI5 控件 customData 属性的应用介绍
SAP UI5 控件 customData 属性的应用介绍
31 0
|
1月前
|
前端开发 JavaScript API
SAP UI5 sap.ui.require.toUrl 的作用介绍
SAP UI5 sap.ui.require.toUrl 的作用介绍
28 0
|
1月前
|
JSON 前端开发 测试技术
SAP UI5 sap.ui.core.util.MockServer.simulate 方法介绍
SAP UI5 sap.ui.core.util.MockServer.simulate 方法介绍
21 0
|
1月前
|
搜索推荐
SAP UI5 SmartTable.prototype._onMetadataInitialised 方法的深入介绍
SAP UI5 SmartTable.prototype._onMetadataInitialised 方法的深入介绍
32 0