How to avoid avoid scheduling overlapped appointments

Hi Support:

We need to avoid our user to create new appointments that overlap their existing appointments. 

I found a similar question link

But in that decision, I can change the meeting (through the editor or by dragging) so that it will overlap other meetings, how to prevent simultaneous events completely?

3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team February 7, 2018 05:54 PM UTC

Hi Vladimir, 
 
Thank you for contacting Syncfusion support. 
 
In that forum, customization has been done only within the appointment creation event, we have modified the same sample which works in create/edit/drag and resize actions.  
 
<Code> 
beforeAppointmentCreate: "OnBeforeAppointmentCreate", 
beforeAppointmentChange: "OnBeforeAppointmentChange", 
dragStop: "OnChange", 
resizeStop: "OnChange", 
 
function OnBeforeAppointmentCreate(args) { 
    if (ej.isNullOrUndefined(args.appointment[0])) 
        app = args.appointment; 
    else 
        app = args.appointment[0]; 
    overlapList = this._overlapApp(app["AppTaskId"], app[this._appointmentSettings["startTime"]], app[this._appointmentSettings["endTime"]], ""); 
    if (overlapList.length > 0) 
        args.cancel = true; 
} 
function OnBeforeAppointmentChange(args) { 
    overlapList = this._overlapApp(args.appointment.changed[0]["AppTaskId"], args.appointment.changed[0][this._appointmentSettings["startTime"]], args.appointment.changed[0][this._appointmentSettings["endTime"]], ""); 
    if (overlapList.length > 0) 
        args.cancel = true; 
} 
function OnChange(args) { 
    overlapList = this._overlapApp(args.appointment["AppTaskId"], args.appointment[this._appointmentSettings["startTime"]], args.appointment[this._appointmentSettings["endTime"]], ""); 
    if (overlapList.length > 0) 
        args.cancel = true; 
} 
</Code> 
 
Regards, 
Karthigeyan 
 



VL Vladimir February 7, 2018 08:28 PM UTC

Hi, thanks for the reply.
And the opportunity to stretch the meeting does not work. It's impossible?

And now it's impossible to change the duration of the meeting ((


KK Karthigeyan Krishnamurthi Syncfusion Team February 8, 2018 05:12 PM UTC

Hi Vladimir, 
 
We have modified the below sample, kindly refer it. 
 
<Code> 
beforeAppointmentCreate: "OnBeforeAppointmentCreate", 
beforeAppointmentChange: "OnEdit", 
dragStop: "OnEdit", 
resizeStop: "OnResize" 
 
function OnBeforeAppointmentCreate(args) { 
    if (ej.isNullOrUndefined(args.appointment[0])) 
        app = args.appointment; 
    else 
        app = args.appointment[0]; 
    overlapList = this._overlapApp(app["AppTaskId"], app[this._appointmentSettings["startTime"]], app[this._appointmentSettings["endTime"]], ""); 
    if (overlapList.length > 0) 
        args.cancel = true; 
} 
function OnEdit(args) { 
    if (args.type == "beforeAppointmentChange") { 
        app = args.appointment.changed[0]; 
    } 
    else { 
        if (ej.isNullOrUndefined(args.appointment[0])) 
            app = args.appointment; 
        else 
            app = args.appointment[0]; 
    } 
    var predicate1 = ej.Predicate(this._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, app.StartTime).and(this._appointmentSettings["endTime"], ej.FilterOperators.greaterThanOrEqual, app.EndTime); 
    var predicate2 = ej.Predicate(this._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, app.StartTime).and(this._appointmentSettings["endTime"], ej.FilterOperators.lessThanOrEqual, app.EndTime); 
    var predicate = predicate2["or"](predicate1); 
    var overlapList = new ej.DataManager(this._processed).executeLocal(new ej.Query().where(predicate1)); 
    var predicate12 = ej.Predicate(this._appointmentSettings["id"], ej.FilterOperators.notEqual, app.Id); 
    var overlapNewList = new ej.DataManager(overlapList).executeLocal(new ej.Query().where(predicate12)); 
    if (overlapNewList.length > 0) 
        args.cancel = true; 
} 
function OnResize(args) { 
    overlapList = this._overlapApp(args.appointment["AppTaskId"], args.appointment[this._appointmentSettings["startTime"]], args.appointment[this._appointmentSettings["endTime"]], null); 
    if (overlapList.length > 1) 
        args.cancel = true; 
} 
</Code> 
 
Regards, 
Karthigeyan 


Loader.
Up arrow icon