<ejs-schedule id="schedule" height="520px" selectedDate="new DateTime(2019, 3, 12)" actionBegin="onActionBegin" dataBound="onDataBound">
<e-schedule-eventsettings dataSource="ViewBag.appoint">
</e-schedule-eventsettings>
<e-schedule-group resources="@ViewBag.Resources"></e-schedule-group>
<e-schedule-resources>
<e-schedule-resource dataSource="@ViewBag.Airlines" field="AirlineId" title="Airline Name" name="Airlines" textField="AirlineName" idField="AirlineId" colorField="AirlineColor" allowMultiple="false"></e-schedule-resource>
</e-schedule-resources>
</ejs-schedule>
function onActionBegin(args) {
if (args.requestType === 'eventCreate' || args.requestType === 'eventChange') {
var data = (args.requestType === 'eventCreate') ? args.data[0] : (args.data);
var groupIndex = this.eventBase.getGroupIndexFromEvent(data);
if (!this.isSlotAvailable(data.StartTime, data.EndTime, groupIndex)) {
args.cancel = true;
flag = true;
alert("Slot must be available");
}
}
}
function onDataBound() {
var scheduleObj = document.getElementById('schedule').ej2_instances[0];
scheduleObj.eventWindow.dialogObject.beforeClose = function (args) {
args.cancel = flag;
flag = false;
}
} |