我想在带有oData V4的UI5 PlanningCalendar中显示事件项,但是有问题。
OData V4的StartDate和EndDate的元数据类型为Edm.Date:
使用数据时收到此错误消息:
这是oData V4中的实际数据:
这是XML视图:
<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="ARN.ARN.controller.AppPOR" xmlns="sap.m" xmlns:unified="sap.ui.unified"
xmlns:l="sap.ui.layout">
<Page showHeader="true" title="{i18n>ApplicationPlanofRecord}" showFooter="true" showNavButton="true" navButtonPress="doNavBack">
<l:DynamicSideContent id="DynamicSideContent" class="sapUiDSCExplored sapUiContentPadding" sideContentVisibility="AlwaysShow"
showSideContent="{path: 'stateModel>/legendShown'}" containerQuery="true" breakpointChanged="updateToggleButtonState">
<l:mainContent>
<VBox>
<PlanningCalendar id="por" startDate="{/startDate}"
rows="{model: 'zearnModel', path: '/zearn_por_applications',
parameters : {$expand : 'EventItem'},
sorter: [{ path: 'APPLICATION_ID', descending: false}],
events: {dataReceived : '.onDataEvents' }, templateShareable:true}"
legend="PlanningCalendarLegend" appointmentsVisualization="Filled" appointmentSelect="handleAppointmentSelect"
showEmptyIntervalHeaders="false" viewKey="M">
<toolbarContent>
<ToolbarSpacer/>
<ToggleButton pressed="{path: 'stateModel>/legendShown'}" icon="sap-icon://legend" tooltip="Legend"/>
</toolbarContent>
<views>
<PlanningCalendarView key="D" intervalType="Day" description="{i18n>WeekView}" intervalsS="1" intervalsM="3" intervalsL="7"
showSubIntervals="true"></PlanningCalendarView>
<PlanningCalendarView key="M" intervalType="Month" description="{i18n>MonthView}" intervalsS="1" intervalsM="1" intervalsL="1"
showSubIntervals="true"></PlanningCalendarView>
<PlanningCalendarView key="Y" intervalType="Month" description="{i18n>YearlyView}" intervalsS="60" intervalsM="60" intervalsL="60"
showSubIntervals="true"></PlanningCalendarView>
<PlanningCalendarView key="Q" intervalType="Month" description="{i18n>QuarterlyView}" intervalsS="4" intervalsM="4" intervalsL="4"
showSubIntervals="true"></PlanningCalendarView>
</views>
<rows>
<PlanningCalendarRow title="{zearnModel>PRODUCT_NAME_SHORT}"
appointments="{model: 'zearnModel', path : 'EventItem', templateShareable: 'true'}"
text="{zearnModel>PRODUCT_NAME_CAPTION}}" icon="" selected="false">
<appointments>
<unified:CalendarAppointment title="{zearnModel>EVENT_DESC}" text="{zearnModel>EVENTTYPE_DESC}" icon="sap-icon://family-care"
startDate="{path: 'zearnModel>STARTDATE', type: 'sap.ui.model.odata.type.Date', formatter: '.formatter.date'}"
endDate="{path: 'zearnModel>ENDDATE', type: 'sap.ui.model.odata.type.Date', formatter: '.formatter.date'}"
type="{path: 'zearnModel>EVENTTYPE_DESC', formatter: '.formatter.PORType'}" selected="false" tentative="false"/>
</appointments>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</l:mainContent>
<l:sideContent width="200px">
<PlanningCalendarLegend id="PlanningCalendarLegend" appointmentItems="{path : '/legendAppointmentItems', templateShareable: 'true'}"
standardItems="Today">
<appointmentItems>
<unified:CalendarLegendItem text="{text}" type="{type}" tooltip="{text}"/>
</appointmentItems>
</PlanningCalendarLegend>
</l:sideContent>
</l:DynamicSideContent>
<headerContent>
<OverflowToolbarButton text="{i18n>Plan}" type="Default" icon="sap-icon://filter" iconFirst="true" width="auto" enabled="true"
visible="true" iconDensityAware="false" press="onSearchDialog" tooltip="{i18n>Filter}"/>
</headerContent>
<subHeader/>
<customHeader/>
</Page>
以及formatter.js代码:
sap.ui.define([
], function () {
"use strict";
return {
PORType: function (type) {
return type; //for testing only.
},
date: function(date) {
console.log("XXXXXXXXXXXX");
console.log(date);
return new Date(date); //for testing only
}
};
}
);
我也觉得没有调用formatter函数,UI5只是抛出错误“无法读取属性getTime”,而没有先格式化。这是一个错误吗?
我在这里做错了什么?