我有以下视图,其中包含一个片段:
<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
,但我认为它不适合我的情况。