sapui5 - 如何为片段分配控制器?
问题描述
我有以下视图,其中包含一个片段:
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
controllerName="ch.mindustrie.ZMM_OBJECTS_CLASSES.controller.ClassSelection" xmlns:html="http://www.w3.org/1999/xhtml">
<smartFilterBar:SmartFilterBar id="SelectionFilterBar" entitySet="ZMM_C_CLASSIFICATION" search="onSearchClass">
<smartFilterBar:controlConfiguration>
<smartFilterBar:ControlConfiguration key="ClassType" preventInitialDataFetchInValueHelpDialog="false"></smartFilterBar:ControlConfiguration>
<smartFilterBar:ControlConfiguration key="ClassNum" preventInitialDataFetchInValueHelpDialog="false"></smartFilterBar:ControlConfiguration>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<core:Fragment fragmentName="ch.mindustrie.ZMM_OBJECTS_CLASSES.fragment.Tree" id="TreeFm" type="XML"/>
</mvc:View>
然后,我想为片段分配一个控制器:
sap.ui.define([
"ch/mindustrie/ZMM_OBJECTS_CLASSES/controller/BaseController",
"ch/mindustrie/ZMM_OBJECTS_CLASSES/helper/Message",
"ch/mindustrie/ZMM_OBJECTS_CLASSES/controller/TreeFragment.controller"
], function (BaseController, Message, TreeController) {
"use strict";
return BaseController.extend("ch.mindustrie.ZMM_OBJECTS_CLASSES.controller.ClassSelection", {
onInit: function () {
},
onSearchClass: function () {
const aFilter = this.byId("SelectionFilterBar").getFilters();
},
});
});
TreeController
控制器应分配给具有上述 id 的片段TreeFm
。如何将控制器分配给片段?
我考虑了功能sap.ui.core.Fragment.load
,但我认为它不适合我的情况。
解决方案
推荐阅读
- javascript - 为什么在“onclick”之前触发“onkeydown”回调?
- c - 在计算三个值的中间值的程序中使用宏
- c++ - 访问说明符(私有/公共/受保护)如何在内部工作(限制成员访问)?
- css - Magento 2 部署 CSS 更新
- powerbi - 在 Power BI 中使用 TOPN 函数时的 ASC 参数
- php - str_replace 用于多个 img 类
- r - 使用观察作为条件组合行
- android-studio - 有什么方法可以让 apk 在模拟器上运行吗?
- kubernetes - Kubernetes Job/CronJob 是否支持与 Pod 不同的对象?
- mysql - Percona pt-online-schema-change 无法更改表