带有预约查看器的剑道日历

时间:2013-04-16 07:34:47

标签: asp.net calendar kendo-asp.net-mvc

您好有办法在Kendo日历控件中显示所选日期的约会吗?

有点像,如果我在1月1日预约我的日历应该显示一条消息和日期(在同一个kendo日历控件中)。剩下的日期只是正常风格。

1 个答案:

答案 0 :(得分:1)

您可以在声明日历时通过定义模板功能在每个日期显示自定义内容。将为日历中显示的每个日期调用此函数。以下示例显示了如何执行此操作:

// Define dates that have appointments
var calDates = [];
calDates[+new Date(2013, 0, 1)] = [{ Description: "Appointment foo", Time: "09:00"}];
calDates[+new Date(2013, 0, 2)] = [{ Description: "Appointment bar", Time: "10:00" }, { Description: "Appointment baz", Time: "12:00"}];

// Declare Kendo Calendar
$("#div1").kendoCalendar({ "value": new Date(2013, 0, 1, 0, 0, 0, 0), "month": { "content": "#= BuildDateMarker(data) #"} });

// Template function
function BuildDateMarker(data) {

    // Get any appointments for this date       
    var appointments = calDates[+data.date];

    if (!appointments || appointments == 'undefined') {
        // No appointments for this date, so return default marker (day of the month)
        return data.date.getDate();
    }

    // Open marker
    var marker = '<div class="appointments" title="' + data.date + '">';

    // Add item for each of this date's appointments
    for (var i = 0; i < appointments.length; i++) {
        var appointment = appointments[i];
        marker += '<span class="appointment">' + appointment.Description + ', at ' + appointment.Time + '</span>';
    }

    // Close marker
    marker += '</div>';

    return marker;
}