This is a migrated thread and some comments may be shown as answers.

Disable specific dates from being edited / inserted

5 Answers 160 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Tobe
Top achievements
Rank 1
Tobe asked on 23 Jul 2010, 10:27 PM
How can I disable all dates from being edited or having appointments inserted into that are earlier than the current date?  I've seen some suggestion of intercepting the insert / update events and checking condition, then setting event to cancel. 

Not sure if this route is the only solution, but seems like letting the user attempt to insert or update a record, only to cancel the event after the fact is not as desirable than just disabling the edit functionality all together.

Thanks-

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Jul 2010, 01:36 PM
Hello Tobe,

There is kb article which you can use for reference:
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/setting-special-days-or-time-slots-in-radscheduler.aspx

It is using the approach that you have already thought of. I am not sure why you need to avoid canceling appointment insert? Are there any special requirements that we should be aware of?


Best wishes,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tobe
Top achievements
Rank 1
answered on 28 Jul 2010, 05:59 PM
I was under the impression the cancel event would happen AFTER the user tried to enter / update data (code behind)...which would be confusing to the user.  The javascript in the KB you sent does alleviate that scenario.

However, one thing the KB doesn't address is how to remove the red delete "X" button on appointments that have been styled as Disabled?

I did add some javascript for the "OnClientAppointmentDeleting" event, however this still allows the yes/no dialog box to appear before canceling the event if yes is selected. 

I would like there to not be an option to hide the delete button for any appointment that has been styled as disabled.

Also, it seems the javascript in the KB article does disable the double clicking of timeslots that have no appointments (insert), but I can still double click on an existing appointment that has been styled as disabled, and the advanced edit box shows up allowing the user to attempt to edit the data.

Thanks-
0
Veronica
Telerik team
answered on 04 Aug 2010, 01:40 PM
Hi Tobe,

Please accept my appologies for the late response.

You can cancel the edit and delete of appointments which have been disabled by this code:

protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
        foreach (DateTime dt in SpecialDays)
        {
            if ((DateTime.Compare(e.Appointment.Start.Date, dt) == 0) || (DateTime.Compare(e.Appointment.End.Date, dt) == 0))
            {
                e.Appointment.AllowEdit = false;
                e.Appointment.AllowDelete = false;
            }
        }
    }

This way the delete button will not be visible only for this appointments. Also you can not edit them as they are in the category of "disabled".

However there is one thing still confusing in the KB. If you try to edit the start or end date of a normal appointment to one of the Special days - it is not allowed. However the user is not informed about what is going on because only the event is cancelled. I've added a message:
 
 
protected void RadScheduler1_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
   {
       foreach (DateTime dt in SpecialDays)
       {
           if ((DateTime.Compare(e.ModifiedAppointment.Start.Date, dt) == 0) || (DateTime.Compare(e.ModifiedAppointment.End.Date, dt) == 0))
           {
               e.Cancel = true;
               ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('The duration of appointment contains Special Days!');", true);
           }
       }
   }

Find the full code in the attached .zip file. 

The KB will be extended too.

Hope this helps.

All the best,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Marc
Top achievements
Rank 1
answered on 09 Sep 2010, 12:25 AM
In the method RadScheduler1_AppointmentUpdate when when you set e.cancel to true the edit form is then reset (no subject and default start/stop days).  How can I just cancel out of the edit form entirely in this method and or retain the edit form values?
0
Veronica
Telerik team
answered on 13 Sep 2010, 10:15 AM
Hi Marc Miles,

I've tested to Update an appointment that starts on one of "special" days. The Warning message: "The duration of appointment contains Special Days!" appeared. However the form is not cleared after that. Subject stays and the datePickers are still showing the last enetered days.

Have you set some additional properties to the Scheduler different from these in the attached code in my previous post? If yes- could you please send me the full code so I can inspect it and help you?
 
Kind regards,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Tobe
Top achievements
Rank 1
Answers by
Peter
Telerik team
Tobe
Top achievements
Rank 1
Veronica
Telerik team
Marc
Top achievements
Rank 1
Share this question
or