扩展 SAP Fiori 应用程序 - 在页脚中添加按钮

问题描述 投票:0回答:2

我正在扩展 hcm.emp.payslip 应用程序,需要在页脚中添加一个按钮....正确的做法是什么?..

选项1:按照本pdf第13页所述放置扩展点.. - 它不起作用..我完全按照提到的步骤进行操作。或者这会不起作用,因为我们自己插入了扩展点,而现在不支持扩展点。?

选项2:按照here所述扩展UI控制器挂钩——我无法尝试这个,因为文档非常简短,而且我是初学者......而且我不确定我们是否可以通过扩展控制器来更改视图

我正在使用eclipse,并安装了工具包插件,我看到有些地方他们推荐使用Web IDE,但我们想使用工具包来完成,因为我不确定我们是否有云HANA访问权限。 或者使用UI工具包的方式还可以吗..

想建议正确的方法和详细步骤...

sapui5 sap-fiori
2个回答
2
投票

你的选项1是不可能的(为什么?因为要向页脚添加按钮,有

controllerHook
不是UI扩展点)

使用选项2,应用程序的详细信息页面的所有控制器(S3.controller.jS3_phone.controller.js)中已经给出了extensionHook。

controllerHook:

extHookChangeFooterButtons

默认情况下 SAP 构建 headerFooterOptions 并将该对象发送到您的扩展 Hook

/**
         * @ControllerHook Modify the footer buttons
         * This hook method can be used to add and change buttons for the detail view footer
         * It is called when the decision options for the detail item are fetched successfully
         * @callback hcm.emp.payslip.view.S3_Phone~extHookChangeFooterButtons
         * @param {object} objHdrFtr-Header Footer Object
         * @return {object} objHdrFtr-Header Footer Object
         */

        if (this.extHookChangeFooterButtons) {
            objHdrFtr = this.extHookChangeFooterButtons(objHdrFtr);
        }

因此,您在扩展控制器中,收到相同的附加:

extHookChangeFooterButtons: function (objHdrFtr) {
    //first if the buttonsList is empty, create one. 
    //Actually in S3.controller.js buttonsList is not defined since there are no buttons
    if (!objHdrFtr.buttonList) {
        objHdrFtr.buttonList = [];
    }
    //then create a button:
    var extendedButton = {
        sId: "EXT_BUTTON",
        sI18nBtnTxt: "SAMPLE", //make sure you add texts in respective i18n files
        bEnabled: true,
        onBtnPressed: function (evt) {
            that.handleExtButtonPress(evt);
        }
    };
    objHdrFtr.buttonList.append(extendedButton)
    //as you can see SAP says to return the object
    return objHdrFtr;
}

建议:在Web IDE中很容易做到。 为什么?

  • 无需时间设置。
  • 非常容易使用,节省大量时间
  • 显示所有controllerHooks, UI 中的扩展点

1
投票

对于 Fiori Inbox 中的上述示例,请使用 B.aButtonList.push(extendedButton);这会将按钮添加到列表末尾(而不是追加)

© www.soinside.com 2019 - 2024. All rights reserved.