We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Limiting the amount of appointment by time

I am trying to add the schedule control to one of our application. In this the user will be able to add an appointment, but he cannot add an appointment at a time that already has 2 in a time period. 

Ex: there is already 2 appointment from 2:00 to 3:00 but the user tries to add one at 1:30 to 2:30. the schedule will validate the date and deny the user the ability to add that appointment until he changes the date and time.

Is there a functionnality for that? 

2 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team March 2, 2017 02:13 PM UTC

Hi Jan, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the sample to prevent the rendering of an appointment in the time range of an already rendered appointments which can be download from the below location. 
 
In the sample, initially two appointment will render in same day and same time. When  3rd appointment is created in already rendered appointment interval range it will not be created. Kindly refer the below code example used in the sample. 
 
<Code> 
function onBeforeAppointmentCreate(args) { // this function will be called before saving an app  
        var curApps = (ej.isNullOrUndefined(args.appointment[0])) ? args.appointment : args.appointment[0]; 
        var proxy = this, _appList = this._processed, appointmentsList = [], app = [], appList = [], overlapList = []; 
        appointmentsList = _appList.filter(function (obj) { return obj[proxy._appointmentSettings["endTime"]] > curApps[proxy._appointmentSettings["startTime"]] && obj[proxy._appointmentSettings["startTime"]] < curApps[proxy._appointmentSettings["endTime"]]; }); 
        appointmentsList.forEach(function (obj) { 
            appList = _appList.filter(function (list) { return list[proxy._appointmentSettings["endTime"]] >= new Date(obj[proxy._appointmentSettings["startTime"]]) && list[proxy._appointmentSettings["startTime"]] <= new Date(obj[proxy._appointmentSettings["endTime"]]); }); 
            var collection = $(appList).not(appointmentsList); 
            if (collection.length != 0) app = $.merge(app, collection); 
            return app; 
        }); 
        overlapList = $.merge(appointmentsList, app); 
        args.cancel = (overlapList.length > 1); 
    } 
</Code> 
 
 Regards, 
Karthigeyan 



KK Karthigeyan Krishnamurthi Syncfusion Team March 2, 2017 02:14 PM UTC

Hi Richard, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the sample to prevent the rendering of an appointment in the time range of an already rendered appointments which can be download from the below location. 
 
In the sample, initially two appointment will render in same day and same time. When  3rd appointment is created in already rendered appointment interval range it will not be created. Kindly refer the below code example used in the sample. 
 
<Code> 
function onBeforeAppointmentCreate(args) { // this function will be called before saving an app  
        var curApps = (ej.isNullOrUndefined(args.appointment[0])) ? args.appointment : args.appointment[0]; 
        var proxy = this, _appList = this._processed, appointmentsList = [], app = [], appList = [], overlapList = []; 
        appointmentsList = _appList.filter(function (obj) { return obj[proxy._appointmentSettings["endTime"]] > curApps[proxy._appointmentSettings["startTime"]] && obj[proxy._appointmentSettings["startTime"]] < curApps[proxy._appointmentSettings["endTime"]]; }); 
        appointmentsList.forEach(function (obj) { 
            appList = _appList.filter(function (list) { return list[proxy._appointmentSettings["endTime"]] >= new Date(obj[proxy._appointmentSettings["startTime"]]) && list[proxy._appointmentSettings["startTime"]] <= new Date(obj[proxy._appointmentSettings["endTime"]]); }); 
            var collection = $(appList).not(appointmentsList); 
            if (collection.length != 0) app = $.merge(app, collection); 
            return app; 
        }); 
        overlapList = $.merge(appointmentsList, app); 
        args.cancel = (overlapList.length > 1); 
    } 
</Code> 
 
 Regards, 
Karthigeyan 


Loader.
Up arrow icon