Hi,
I ran into a few issues while doing web service binding (custom provider) and using a custom advanced form. I figured ways around it/fixes and wanted to know if I'm going about this correctly or is there better ways (the documentation for the scheduler client side stuff is not that great):
1) I have a recurring appointment in the scheduler. When I click the "master appointment" and select "edit series" it loads up fine BUT if I click an "Occurrence" of the series and select "edit series" the time slots are populated with the dates/times of the current occurrence (not master) and the recurrence panel does not load up correctly (this can get very annoying because I'm building an employee timesheet where an occurrence can repeat for 1+ years).
The issue here is that the "schedulerFormCreated" client side function tries to load the data for the current occurrence which does not have the recurrence rules - I am selecting "edit series" not "current appointment" so it should be loading the master.
The way I solved this:
I added the if statement to check if it the appointment is an Occurrence; if so get its parent and load the data for the parent in the form.
Also the recurrence panel loads if you select the master appointment and select "edit current appointment" (not series) - it should stay closed since we're only editing the current appointment. A line or two in the populate method in AdvancedForm.js fixed this.
2) Cannot delete a single occurrence of a recurring appointment (building a employee timesheet system - for example have to delete a single instance if somebody is out sick a certain day).
My web service method (this is from the tutorial):
Custom Provider:
The issue that happened to me here is that the web service calls the Delete method of the custom provider even if the appointment is an occurrence and the linq statement fails because there is no database entry for an occurrence of an appointment (only for the masters and exceptions there are db entries) - to "delete" an occurrence you have to add an exception to the RecurrenceRule of the master appointment.
What I did here is modify the DeleteAppointment method:
- if delete series or master or exception do return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries);
- if delete single appointment check if appointment is master if master get the RecurrenceRule (from db) if an Occurrence get the master appointment then get its RecurrenceRule (from db). Then I used the RecurrenceRuleConverter to convert from recurrence string then add an exception for the "Start" property of the passed "appointmentData" then convert back to string, save to database, and reload appointments.
Am I going about this the right way? Maybe there's an easier method but I've searched the documentation/forums with no luck...
I ran into a few issues while doing web service binding (custom provider) and using a custom advanced form. I figured ways around it/fixes and wanted to know if I'm going about this correctly or is there better ways (the documentation for the scheduler client side stuff is not that great):
1) I have a recurring appointment in the scheduler. When I click the "master appointment" and select "edit series" it loads up fine BUT if I click an "Occurrence" of the series and select "edit series" the time slots are populated with the dates/times of the current occurrence (not master) and the recurrence panel does not load up correctly (this can get very annoying because I'm building an employee timesheet where an occurrence can repeat for 1+ years).
The issue here is that the "schedulerFormCreated" client side function tries to load the data for the current occurrence which does not have the recurrence rules - I am selecting "edit series" not "current appointment" so it should be loading the master.
The way I solved this:
if (!scheduler.get_webServiceSettings().get_isEmpty()) { |
// Populate the form with the appointment data |
var apt = eventArgs.get_appointment(); |
var isInsert = mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert; |
var editSeries = eventArgs.get_editingRecurringSeries(); |
if (editSeries && apt.get_recurrenceState() == 2) { |
var ParentID = apt.get_recurrenceParentID(); |
apt = scheduler.get_appointments().findByID(ParentID); |
} |
advancedTemplate.populate(apt, isInsert, editSeries); |
} |
I added the if statement to check if it the appointment is an Occurrence; if so get its parent and load the data for the parent in the form.
Also the recurrence panel loads if you select the master appointment and select "edit current appointment" (not series) - it should stay closed since we're only editing the current appointment. A line or two in the populate method in AdvancedForm.js fixed this.
2) Cannot delete a single occurrence of a recurring appointment (building a employee timesheet system - for example have to delete a single instance if somebody is out sick a certain day).
My web service method (this is from the tutorial):
[WebMethod(EnableSession = true)] |
public IEnumerable<AppointmentData> DeleteAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData, bool deleteSeries) { |
return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries); |
} |
Custom Provider:
public override void Delete(RadScheduler owner, Appointment appointmentToDelete) |
{ |
if (!PersistChanges) |
{ |
return; |
} |
Connectors.TimeLog MyLog = db.TimeLogs.Where(p => p.TimeTableID == (int)appointmentToDelete.ID).First(); |
db.TimeLogs.DeleteOnSubmit(MyLog); |
db.SubmitChanges(); |
} |
The issue that happened to me here is that the web service calls the Delete method of the custom provider even if the appointment is an occurrence and the linq statement fails because there is no database entry for an occurrence of an appointment (only for the masters and exceptions there are db entries) - to "delete" an occurrence you have to add an exception to the RecurrenceRule of the master appointment.
What I did here is modify the DeleteAppointment method:
- if delete series or master or exception do return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries);
- if delete single appointment check if appointment is master if master get the RecurrenceRule (from db) if an Occurrence get the master appointment then get its RecurrenceRule (from db). Then I used the RecurrenceRuleConverter to convert from recurrence string then add an exception for the "Start" property of the passed "appointmentData" then convert back to string, save to database, and reload appointments.
Am I going about this the right way? Maybe there's an easier method but I've searched the documentation/forums with no luck...