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
close icon

Prevent the time slot(cells) for booking in Resource View

Hi,
       I have a scenario like this.

       If Resource 1 is assigned for a particular user(user 1) for specific time(like 26/9/2015 9 am to 10 am),  then he can only book this slot.

       If other user enters into the system, he can not book this slot as this slot is already assigned to user 1.  i want this slot to be disabled(change the color of this cell to gray) for this user.

       Is this possible in schedule control? If yes, give me the solution for this.


Thanks
Saravanan .T

    
       

3 Replies

SK Sarath Kumar P K Syncfusion Team September 28, 2015 04:47 PM UTC

Hi Saravanan,

Thanks for contacting Syncfusion support.

We have prepared a schedule sample to block the time slot with existing appointment which can be downloaded from the following location
http://www.syncfusion.com/downloads/support/forum/120566/ze/TimeSlotBlock1315195735

In the above sample we have used the client side events to check the condition and block the time slot. Please refer to the following code example.
<code>

@(Html.EJ().Schedule("Schedule1")

        .Width("100%")

        -------------------

        -------------------

           .Description("Description")

            )
.ScheduleClientSideEvents(evt => evt.AppointmentWindowOpen("onAppointmentWindowOpen").AppointmentSaved("appValidate").AppointmentEdited("appValidate").ResizeStop("appValidate").DragStop("appValidate")))
//Here we bind the events to block the particular time slot for users

function appValidate(args) {

        var schObj = $("#Schedule1").data("ejSchedule");

        var appList = schObj._processed;

        (args.type == "appointmentSaved" || args.type == "appointmentEdited") && schObj._timeZoneAppointments(args.appointment, "reverse");

        for (var i = 0; i < appList.length; i++) {

            if ((args.type == "appointmentSaved" ? true : (appList[i][schObj.model.appointmentSettings["id"]] != args.appointment.Id)) && (new Date(appList[i][schObj.model.appointmentSettings["endTime"]]) > new Date(args.appointment.StartTime))) {

                if ((new Date(appList[i][schObj.model.appointmentSettings["startTime"]]) < new Date(args.appointment.EndTime))) {

                    // You can write your own condition to block the appointment creation based on the user details. For example, if the resource 1 is assigned to user 1 means you can block the appointment creation for user 2 by checking the condition and setting the args.cancel value as true

                    args.cancel = true;

                    return false;

                }

            }

        }

        (args.type == "appointmentSaved" || args.type == "appointmentEdited") && schObj._timeZoneAppointments(args.appointment, "");
    }
</code>

Regards,
Sarath Kumar P K



MH Michael Hehl February 24, 2017 08:51 PM UTC

Did you ever get this working? I'm trying to do the same thing. 

I want to be able to block room 1 for user 1 for a period of time. Only that user can create appointments for that room during that block. 


KK Karthigeyan Krishnamurthi Syncfusion Team February 27, 2017 10:15 AM UTC

Hi Michael, 
 
We have prepared the sample to reserve the particular time slot for a particular resource in partiular room and the sample can be download from the below location. 
 
In the sample, timeslot 10AM-12PM of today in Room1 is allocated for Nancy and other resource (Michael) in Room1 cannot create appointment in that time slot. Kindly refer the below code example used in the sample. 
 
<Code> 
function onBeforeAppointmentCreate(args) { 
        strTime = new Date().setHours(10, 0, 0, 0); 
        endTime = new Date().setHours(12, 0, 0, 0); 
        app = (ej.isNullOrUndefined(args.appointment[0])) ? args.appointment : args.appointment[0]; 
        if (strTime <= app.StartTime.getTime() && endTime >= app.EndTime.getTime() && app.RoomId == 1 && app.OwnerId != 1) 
            args.cancel = true 
    } 
<style> 
     .e-appointment { 
            width: 100% !important; 
        } 
</style> 
</Code> 

Regards, 
Karthigeyan 


Loader.
Live Chat Icon For mobile
Up arrow icon