我遇到一个问题,当我向日历中添加事件时,该事件将不会显示在日历上。我需要在按钮上单击一下还是应该解决此问题?请帮忙。我的代码下方是否有解决方法,请提供建议或帮助。非常感谢你。这是我的下面的代码。
Javascript:
$(function () {
var PUBLIC_KEY = "PUBLIC_KEY",
CALENDAR_ID = "CALENDAR_ID";
var scheduler = $(".scheduler").dxScheduler({
dataSource: data,
views: ['month', 'week', 'workWeek', 'day', { type: "agenda", agendaDuration: 1 }],
currentView: "month",
currentDate: new Date($.now()),
useDropDownViewSwitcher: false,
firstDayOfWeek: 0,
startDayHour: 8,
endDayHour: 19,
load: function (options) {
var result = $.Deferred();
$.ajax({
data: { showDeleted: false },
dataType: "json",
url: [
"https://www.googleapis.com/calendar/v3/calendars/",
CALENDAR_ID,
"/events?key=",
PUBLIC_KEY
].join("")
}).done(function (response) {
result.resolve(response.items);
});
return result.promise();
},
resources: [{
fieldExpr: "ownerId",
allowMultiple: true,
label: "Owner"
}],
onContentReady: function (e) {
var $element = e.element.find('.dx-scheduler-dropdown-appointments');
$element.click(function (ea) {
var startDate = new Date($($element).dxDropDownMenu('instance').option('items')[0].startDate);
e.component.option('currentDate', startDate);
e.component.option("currentView", "agenda");
ea.preventDefault();
ea.stopPropagation();
});
},
width: "100%",
height: 600
}).dxScheduler("instance");
});
$(document).on('click', 'td.dx-scheduler-focused-cell', function (e) {
//show the form
$('.modal').modal('show')
})
var data = [
];
HTML:
<form>
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="ScheduleStartTime" class="control-label"></label>
<input asp-for="ScheduleStartTime" class="form-control" id="scheduleStartTime" />
<span asp-validation-for="ScheduleStartTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="CandidateID" class="control-label"></label>
<select asp-for="CandidateID" class="form-control">
<option value="9f0ce1e8" id="vName">John Doe</option>
<option value="f99088a0">Jane Doe</option>
<option value="e432ed26">Mary Doe</option>
</select>
<br />
<span asp-validation-for="CandidateID" cla 4ss="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ExamId" class="control-label"></label>
<select class="form-control" asp-for="ExamId">
</select>
<br />
</div>
<div class="form-group">
<input type="submit" onclick="myFunction()" value="Add to Calendar" class="btn btn-primary" />
</div>
</form>