I’m a Newbie using schedule JavaScript (Essential JS 1)… exist the possibility to make an appointment not with right click or Enter but with mouseUp in JavaScript? I will select for example 2 Days with the mouse and when the mouse is up make an appointment. It’s Possible?
|
$(function () {
var dManager = ej.DataManager(window.Default).executeLocal(ej.Query().take(1));
$("#Schedule1").ejSchedule({
width: "100%",
height: "525px",
currentDate: new Date(2014, 4, 5),
showQuickWindow: false,
allowDragAndDrop: false,
appointmentSettings: {
dataSource: dManager,
id: "Id",
subject: "Subject",
startTime: "StartTime",
endTime: "EndTime",
description: "Description",
allDay: "AllDay",
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule"
},
create: "onCreate",
resizeStart: function (args) {
args.cancel = true;
}
});
});
function onCreate(args) {
this._on(this.element, "mouseup", ".e-workcells,.e-alldaycells,.e-monthcells", $.proxy(onMultiCellSelection, this));
}
function onMultiCellSelection(e) {
var obj = {};
var scheduleObj = $("#Schedule1").ejSchedule("instance");
var result = scheduleObj.getSlotByElement(); // to get the selected cell details
console.log(result);
if (result) {
obj["StartTime"] = result.startTime;
obj["EndTime"] = result.endTime;
scheduleObj.saveAppointment(obj);
}
} |
|
<script type="text/javascript">
$(function () {
var dManager = ej.DataManager(window.Default).executeLocal(ej.Query().take(1));
$("#Schedule1").ejSchedule({
width: "100%",
height: "525px",
currentDate: new Date(2014, 4, 5),
showQuickWindow: false,
allowDragAndDrop: false,
appointmentSettings: {
dataSource: dManager,
id: "Id",
subject: "Subject",
startTime: "StartTime",
endTime: "EndTime",
description: "Description",
allDay: "AllDay",
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule"
},
create: "onCreate",
resizeStart: function (args) {
args.cancel = true;
},
beforeAppointmentCreate: "OnBeforeAppointmentCreate"
});
});
function onCreate(args) {
this._on(this.element, "mouseup", ".e-workcells,.e-alldaycells,.e-monthcells", $.proxy(onMultiCellSelection, this));
}
function onMultiCellSelection(e) {
var obj = {};
var scheduleObj = $("#Schedule1").ejSchedule("instance");
var result = scheduleObj.getSlotByElement(); // to get the selected cell details
console.log(result);
if (result) {
obj["StartTime"] = result.startTime;
obj["EndTime"] = result.endTime;
if ($(e.target).attr("class") !== "e-icon e-schedulemouseclose")
scheduleObj.saveAppointment(obj);
}
}
</script>
|
|
<script type="text/javascript">
$(function () {
var dManager = ej.DataManager(window.Default).executeLocal(ej.Query().take(1));
$("#Schedule1").ejSchedule({
width: "100%",
height: "525px",
currentDate: new Date(2014, 4, 5),
showQuickWindow: false,
allowDragAndDrop: false,
appointmentSettings: {
dataSource: dManager,
id: "Id",
subject: "Subject",
startTime: "StartTime",
endTime: "EndTime",
description: "Description",
allDay: "AllDay",
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule"
},
create: "onCreate",
resizeStart: function (args) {
args.cancel = true;
},
beforeAppointmentCreate: "OnBeforeAppointmentCreate"
});
});
function OnBeforeAppointmentCreate(args) {
var schObj = $("#Schedule1").ejSchedule('instance');
if (ej.isNullOrUndefined(args.appointment[0]))
obj = args.appointment;
else
obj = args.appointment[0];
var predicate = ej.Predicate(schObj._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, new Date(obj.StartTime)).and(schObj._appointmentSettings["endTime"], ej.FilterOperators.greaterThanOrEqual, new Date(new Date(obj.EndTime)));
// if newly rendered appointment range has another appointment it will be retrieved here
var newAppList = new ej.DataManager(schObj._processed).executeLocal(new ej.Query().where(predicate));
if (newAppList.length > 0) // 0 indicates no more appointment should render in the same time range
args.cancel = true;
}
</script>
|
I don't know how to explain it. I try to explain better.
One appointment
came from the Database and should remain.
The second entry I just created with the mouse-down method. This already works.
If I do a new one, the previous entry should be deleted. No matter where and in which column it was generated but not that came from
the database.
That was the idea I'm trying to implement.
|
function OnBeforeAppointmentCreate(args) {
var schObj = $("#Schedule1").ejSchedule('instance');
if (ej.isNullOrUndefined(args.appointment[0]))
obj = args.appointment;
else
obj = args.appointment[0];
var predicate = ej.Predicate(
schObj._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, new Date(obj.StartTime))
.and(schObj._appointmentSettings["endTime"], ej.FilterOperators.greaterThanOrEqual, new Date(new Date(obj.StartTime)))
.and(schObj._appointmentSettings["startTime"], ej.FilterOperators.lessThan, new Date(new Date(obj.EndTime)))
.or(schObj._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, new Date(obj.StartTime))
.and(schObj._appointmentSettings["endTime"], ej.FilterOperators.greaterThan, new Date(obj.StartTime));
// if newly rendered appointment range has another appointment it will be retrieved here
var newAppList = new ej.DataManager(schObj._processed).executeLocal(new ej.Query().where(predicate));
if (newAppList.length > 0) { // 0 indicates no more appointment should render in the same time range
for (var i = 0; i < newAppList.length; i++) {
schObj.deleteAppointment(newAppList[i]); // delete the appointment rendered in same time
}
}
} |