我正在尝试将sap.m.PlanningCalendar的扩展名添加到我的XML视图中。添加后,浏览器会显示以下错误消息:
无法添加没有为控件定义的默认聚合的直接子项be.amistaAdminPlanning.controls.MyPlanningCalendar
有没有人可以帮助我或者告诉我我做错了什么?
<mvc:View controllerName="be.amistaAdminPlanning.controller.AdminPlanning" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc" xmlns:unified="sap.ui.unified" displayBlock="true" xmlns="sap.m" xmlns:semantic="sap.m.semantic"
xmlns:controls="be.amistaAdminPlanning.controls">
<App>
<pages>
<semantic:FullscreenPage id="P1" title="{i18n>title}">
<VBox class="sapUiSmallMargin">
<controls:MyPlanningCalendar id="PC1" rows="{path: '/people'}" appointmentsVisualization="Filled" groupAppointmentsMode="expanded"
appointmentsReducedHeight="true" appointmentSelect="onClickAssignment" showEmptyIntervalHeaders="false" viewChange="onStartDateChange"
startDateChange="onStartDateChange">
<toolbarContent>
<Title text="Assignments" titleStyle="H4"/>
<ToolbarSpacer/>
<Button id="addButton" icon="sap-icon://add" press="onAddAssignment" tooltip="Add"/>
</toolbarContent>
<views>
<PlanningCalendarView description="Day" intervalType="Hour" key="Hour" intervalsL="24" intervalsM="6" intervalsS="6"/>
<PlanningCalendarView description="Week" intervalType="Day" key="Day" intervalsL="7" intervalsM="7" intervalsS="7"/>
<PlanningCalendarView description="2 Weeks" intervalType="Week" key="Week" intervalsL="14" intervalsM="14" intervalsS="14"/>
<PlanningCalendarView description="Month" intervalType="One Month" key="One Month" intervalsL="31" intervalsM="1" intervalsS="1"/>
<PlanningCalendarView description="Year" intervalType="Month" key="Month" intervalsL="12" intervalsM="6" intervalsS="3"/>
</views>
<rows>
<PlanningCalendarRow id="PCR1" icon="{pic}" title="{name}" text="{role}" appointments="{path : 'appointments', templateShareable: 'true'}"
intervalHeaders="{path: 'headers', templateShareable: 'true'}">
<appointments>
<CalendarAppointment id="MCA1" startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" text="{info}" type="{type}"
tentative="{tentative}" hover="onAppointmentHover"/>
</appointments>
<intervalHeaders>
<unified:CalendarAppointment startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" type="{type}"></unified:CalendarAppointment>
</intervalHeaders>
</PlanningCalendarRow>
</rows>
</controls:MyPlanningCalendar>
</VBox>
</semantic:FullscreenPage>
</pages>
</App>
sap.ui.define(["sap/m/PlanningCalendar"], function(PlanningCalendar) {
"use strict";
return PlanningCalendar.extend("be.amistaAdminPlanning.controls.MyPlanningCalendar", {
metadata: {
properties: {},
events: {},
aggregations: {}
},
renderer: function(oRm, oControl) {
sap.m.PlanningCalendarRenderer.render(oRm, oControl); //use supercass renderer routine
}
});
});
答案 0 :(得分:0)
您必须在聚合前添加控件XML命名空间:
<controls:MyPlanningCalendar id="PC1" rows="{path: '/people'}">
<controls:toolbarContent>
</controls:toolbarContent>
<controls:views>
</controls:views>
<controls:rows>
</controls:rows>
</controls:MyPlanningCalendar>
这不是特定于您的自定义控件。使用xml命名空间时,您将始终必须这样做。
BR Chris