扩展sap.ui.unified.CalendarAppointment

时间:2017-10-23 08:30:19

标签: javascript sapui5

我目前正在尝试扩展CalendarAppointment(规划日历)。我现在非常困难,我可以使用一些技巧让我回到原地。

我正在尝试将字符串属性“project”添加到CalendarAppointment。下面的代码是我到目前为止的代码。

XML

这是我现在使用的XML。

  <mvc:View
    controllerName="be.amistaplanningadmintool.controller.Board"
    xmlns:mvc="sap.ui.core.mvc"
    xmlns:unified="sap.ui.unified"
    xmlns:custom="be.amistaplanningadmintool.controls"
    xmlns="sap.m">
    <VBox class="sapUiSmallMargin">
        <PlanningCalendar
            id="PC1"
            startDate="{path: '/startDate'}"
            rows="{path: '/people'}"
            appointmentsVisualization="Filled"
            appointmentSelect="handleAppointmentSelect"
            showEmptyIntervalHeaders="false">
            <toolbarContent>
                <Title text="Title" titleStyle="H4"/>
            </toolbarContent>
            <rows>
                <PlanningCalendarRow
                    icon="{pic}"
                    title="{name}"
                    text="{role}"
                    appointments="{path : 'appointments', templateShareable: 'true'}"
                    intervalHeaders="{path: 'headers', templateShareable: 'true'}">
                    <appointments>
                        <custom:CalendarAppointment
                            startDate="{start}"
                            endDate="{end}"
                            icon="{pic}"
                            title="{title}"
                            text="{info}"
                            type="{type}"
                            tentative="{tentative}"
                            project="{project}">
                        </custom:CalendarAppointment>
                    </appointments>
                    <intervalHeaders>
                        <unified:CalendarAppointment
                            startDate="{start}"
                            endDate="{end}"
                            icon="{pic}"
                            title="{title}"
                            type="{type}">
                        </unified:CalendarAppointment>
                    </intervalHeaders>
                </PlanningCalendarRow>
            </rows>
        </PlanningCalendar>
    </VBox>
</mvc:View>

CONTROLLER

这是带有一些硬编码约会的控制器

        sap.ui.define([
        "sap/ui/core/mvc/Controller",
        "sap/ui/model/json/JSONModel",
        "sap/m/MessageBox",
        "be/amistaplanningadmintool/controls/CalendarAppointment"
    ],
    function(Controller, JSONModel, MessageBox) {
        "use strict";
        return Controller.extend("be.amistaplanningadmintool.controller.Board", {

            onInit: function() {
                var oModel = new JSONModel();
                oModel.setData({
                    startDate: new Date("2017", "0", "15", "8", "0"),
                    people: [{
                        pic: "test-resources/sap/ui/demokit/explored/img/John_Miller.png",
                        name: "John Miller",
                        role: "team member",
                        appointments: [{
                            start: new Date("2017", "0", "15", "13", "30"),
                            end: new Date("2017", "0", "15", "17", "30"),
                            title: "Discussion with clients",
                            info: "online meeting",
                            type: "Type02",
                            tentative: false,
                            project: "test project"
                        }]
                    }]
                });
                this.getView().setModel(oModel);

            },

            handleAppointmentSelect: function(oEvent) {
                var oAppointment = oEvent.getParameter("appointment");
                if (oAppointment) {
                    MessageBox.show("Appointment selected: " + oAppointment.getTitle());
                } else {
                    var aAppointments = oEvent.getParameter("appointments");
                    var sValue = aAppointments.length + " Appointments selected";
                    MessageBox.show(sValue);
                }
            }

        });
    });

CONTROL

这是我用来尝试扩展当前控件的控件。

    sap.ui.define(
    ["sap/ui/unified/CalendarAppointment"],
    function(CalendarAppointment) {
        return CalendarAppointment.extend("be.amistaplanningadmintool.controls.CalendarAppointment",{
            metadata: {
                properties: {
                   project: "string"
                }
            },
            renderer: function(oRm, oControl){
                sap.ui.unified.CalendarAppointmentRenderer.render(oRm, oControl); //use supercass renderer routine
            }
        });
    }
);

任何建议或提示都将不胜感激。

由于 大卫

1 个答案:

答案 0 :(得分:0)

&#34;项目&#34;财产是以错误的方式引入的。没有像#34; editable&#34;这样的东西。阅读文档article

关于自定义控件非常棒post