一种简单地实现 SAP UI5 Master detail 页面的方法
生活随笔
收集整理的這篇文章主要介紹了
一种简单地实现 SAP UI5 Master detail 页面的方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
實現效果如下圖所示:
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 displaythis.setDisplayBlock(true);this.app = new sap.m.SplitApp();// load the master pagevar master = sap.ui.xmlview("Master", "jerrylist.view.Master");master.getController().nav = this.getController();this.app.addPage(master, true);// load the empty pagevar empty = sap.ui.xmlview("Empty", "jerrylist.view.Empty");this.app.addPage(empty, false);return this.app;} });代碼第 13 行創建的 sap.m.SplitApp, 實際上是 SplitContainer:
這個 addPage 方法內部,分別調用 addMasterPage 或者 addDetailPage:
此時 detail 頁面是空的:
Master List 點擊事件,注冊在 Master.view.xml 里:handleListSelect
點擊之后,從 event 事件對象里,獲得 binding context:
通過 path 能拿到具體的模型數據:
使用 this.nav.to(“Detail”, context) 跳轉到 detail 頁面:
Master view controller 的 nav 屬性,在 View controller 里被賦值:
在 to 實現里:動態創建一個新的 id 為 Detail 的視圖,然后調用 splitContainer.addPage, 將其加到 Split App 里:
調用 app.to 方法,顯示頁面:
SplitApp to 方法的注釋:
/*** 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*/更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的一种简单地实现 SAP UI5 Master detail 页面的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP UI5 视图如何使用工程里的 s
- 下一篇: 使用 SAP UI5 CLI 命令行工具