如何使用 controllerExtensions 给 SAP Fiori Elements List Report 的表格注册事件响应函数
步驟1:在 manifest.json 的 extends 區(qū)域里,注冊(cè) controllerExtensions:
源代碼:
"extends": {"extensions": {"sap.ui.controllerExtensions": {"sap.suite.ui.generic.template.ListReport.view.ListReport": {"controllerName": "com.sap.jerry.jerryfioriapp.ext.controller.ListReportExtension","sap.ui.generic.app": {"SEPMRA_C_PD_Product": {"EntitySet": "SEPMRA_C_PD_Product","Actions": {"ActionName1": {"id" : "ActionName1","text" : "Jerry的按鈕","press" : "onCustomAction1","global": true}}}}} }}},步驟2:
實(shí)現(xiàn) controller extension:
sap.ui.define("com.sap.jerry.jerryfioriapp.ext.controller.ListReportExtension", [], function() {return {onCustomAction1 : function(oEvent) {alert('Hello');},onAfterRendering: function (oEvent) {debugger;var oContentTable = this.byId("com.sap.jerry.jerryfioriapp::sap.suite.ui.generic.template.ListReport.view.ListReport::SEPMRA_C_PD_Product--responsiveTable");oContentTable.attachSelect(this._onSelectChanged);},_onSelectChanged: function (oEvent) {debugger;}}});步驟3:測(cè)試。
運(yùn)行時(shí),首先觸發(fā) onAfterRendering 鉤子函數(shù),通過byId API,根據(jù) Smart Table 控件 ID,拿到其 table 實(shí)例:
SAP UI5 里所有的運(yùn)行時(shí)創(chuàng)建實(shí)例,都存儲(chǔ)在全局對(duì)象 mInstances 里,鍵為 控件 id,值為控件實(shí)例。
拿到 table 實(shí)例后,調(diào)用其 attach 方法,掛接對(duì)應(yīng)的事件處理函數(shù)。
一切完成后,點(diǎn)擊 Smart Table 某行項(xiàng)目,我們使用 attachSelect 注冊(cè)的事件處理函數(shù)就會(huì)觸發(fā):
本文參考:Fiori Element List Report – Adjust column size automatically
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的如何使用 controllerExtensions 给 SAP Fiori Elements List Report 的表格注册事件响应函数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mrdaloo是什么型号
- 下一篇: 具备自动刷新功能的 SAP ABAP A