|
<div id="radialtarget1" class="content-container-fluid">
<div class="row" id="rteSample1">
<div class="cols-sample-area">
<div style="float: left" id="Schedule1">
</div>
</div>
</div>
<div id="defaultRadialMenu">
<ul>
<li data-ej-imageurl="/fonts/images/add.png"
data-ej-text="Create" data-ej-click="createAppointment"></li>
<li data-ej-imageurl="/fonts/images/edit.png"
data-ej-text="Edit" data-ej-click="editAppointment"></li>
</ul>
</div>
</div>
<script type="text/javascript">
$(function () {
var data = [{
Id: 100,
Subject: "Meeting",
StartTime: new Date(2014, 4, 4, 10, 00),
EndTime: new Date(2014, 4, 4, 11, 00),
AllDay: false,
Recurrence: false,
Status: 'Fixed'
}
];
var dataManager = ej.DataManager({
// get the appointment data from the specified controller action
url: '@Url.Action("GetData","Home")', // This will trigger to bind the appointment data initially to the Schedule control
crudUrl: '@Url.Action("Batch","Home")', // This will trigger while performing CRUD operation on the Scheduler appointments
crossDomain: true,
adaptor: new ej.UrlAdaptor()
});
dataManager.adaptor = new ej.UrlAdaptor();
$("#Schedule1").ejSchedule({
width: "100%",
height: "525px",
beforeAppointmentCreate: "OnBeforeAppointmentCreate",
appointmentClick: "OnAppointmentClick",
cellClick: "OnCellClick",
currentDate: new Date(2015, 5, 15),
appointmentSettings: {
dataSource: dataManager,
id: "Id",
subject: { field: "Subject", validationRules: { required: true } },
startTime: "StartTime",
endTime: "EndTime",
startTimeZone: "StartTimeZone",
endTimeZone: "EndTimeZone",
allDay: "AllDay",
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule"
},
appointmentWindowOpen: "onAppointmentWindowOpen"
});
radialEle = $('#defaultRadialMenu');
if (!(ej.browserInfo().name == "msie" && ej.browserInfo().version < 9)) {
radialEle.ejRadialMenu({ imageClass: "imageclass", backImageClass: "backimageclass" });
}
});
function OnAppointmentClick(args) { // Quick window customization on appointment click
if (!ej.isNullOrUndefined(args.appointment.Status)) {
if ($(".customfields").length == 0) {
var customDesign = "<tr class='customfields'><td>Issue Status</td><td><div class='statusValue'/></td></tr>" +
"<tr class='customfields'><td>Reporter</td><td><div class='reporterValue'/></td></tr>";
$(".e-quicksubject").parent().parent().after(customDesign); // here we are adding the custom fields in app quick window
}
this._quickAppDetailsWindow.find(".statusValue").html(args.appointment.Status);
this._quickAppDetailsWindow.find(".reporterValue").html(args.appointment.Reporter);
}
else {
this._quickAppDetailsWindow.find(".statusValue").html("");
this._quickAppDetailsWindow.find(".reporterValue").html("");
}
}
function OnBeforeAppointmentCreate(args) {
// checks if the subject value is not left blank before saving it.
args.appointment["Subject"] = this._quickAppointWindow.find('.subject').val();
args.appointment["Status"] = this._quickAppointWindow.find('.Status').val();
args.appointment["Reporter"] = this._quickAppointWindow.find('.Reporter').val();
}
var celltarget = '';
function OnCellClick(args) { // Quick window customization ob cell click
celltarget = args.target;
$("#delRea1").show();
if ($(".customfields1").length == 0) {
var customDesign1 = "<tr class='customfields1'><td class='customlabel'>Status</td><td><input name='Status' class='Status' type='text'/></td></tr>" +
"<tr class='customfields1'><td class='customlabel'>Reporter</td><td><input name='Reporter' id='Report' class='Reporter' type='text'/></td></tr>" +
"<tr ><td></td><td class='customlabel'><button id='delRea1'>Click me to show radial menu</button></td></tr>";
$(".e-subjectlabel").parent().after(customDesign1); // here we are adding the custom fields in quick window
}
$('.e-quickcreatebottomcontainer').hide();
this._quickAppointWindow.find(".Status").val("");
this._quickAppointWindow.find(".Reporter").val("");
$("#delRea1").click(function (e) { // Radial menu open on button click
$("#delRea1").hide();
var target = $("#radialtarget1"), radialRadius = 150, radialDiameter = 2 * radialRadius,
// To get Iframe positions
iframeY = e.clientY, iframeX = e.clientX,
// To set Radial Menu position within target
x = iframeX > target.width() - radialRadius ? target.width() - radialDiameter : (iframeX > radialRadius ? iframeX - radialRadius : 0),
y = iframeY > target.height() - radialRadius ? target.height() - radialDiameter : (iframeY > radialRadius ? iframeY - radialRadius : 0);
$('#defaultRadialMenu').ejRadialMenu("setPosition", x, y);
});
}
function createAppointment(args) { // Appointment Save
var appointment = {};
var obj = $("#Schedule1").data("ejSchedule");
var result = obj.getSlotByElement(); // to get the selected cell details
if (result) {
appointment["StartTime"] = result.startTime;
appointment["EndTime"] = result.endTime;
if (result.resources) {
appointment["roomId"] = result.resources.id;
}
obj.saveAppointment(appointment);
obj._quickWindowClose();
$("#defaultRadialMenu").ejRadialMenu("hide");
//$("#delRea1").close();
}
}
function editAppointment(args) {
debugger;
var obj = $("#Schedule1").data("ejSchedule");
if (celltarget != '')
obj._appointmentWindow(celltarget);
$("#defaultRadialMenu").ejRadialMenu("hide");
}
function onAppointmentWindowOpen(args) {
// args.cancel = true; // prevents the display of default appointment window
var schObj = $("#Schedule1").data("ejSchedule");
debugger;
// If double clicked on the appointments, fill the custom appointment window fields with appropriate values.
if (!ej.isNullOrUndefined(args.appointment)) {
$("#customId").val(args.appointment.Id);
$("#subject").val(args.appointment.Subject);
}
}
</script> |