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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

120566 Sep 25,2015 12:22 PM Feb 27,2017 05:15 AM ASP.NET MVC 3
loading
Tags: Schedule
saravanan
Asked On September 25, 2015 12:22 PM

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

    
       

Sarath Kumar P K [Syncfusion]
Replied On September 28, 2015 12:47 PM

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


Michael Hehl
Replied On February 24, 2017 03:51 PM

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. 

Karthigeyan Krishnamurthi [Syncfusion]
Replied On February 27, 2017 05:15 AM

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;