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

web service binding questions

3 Answers 137 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Pedro Cordero
Top achievements
Rank 1
Pedro Cordero asked on 31 Mar 2010, 10:35 PM
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:

                 
                    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...

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 06 Apr 2010, 05:27 PM
Hi Pedro,

Thank you for reporting these issues in such detail. I can confirm that both are bugs and the problem is not in your code.

The cause of the first issue is that the formCreated event arguments always contain a reference to the currently selected appointment. They should point to the master / newly created exception instead.

As for the second problem - the delete method should never be called with an occurrence in the first place. It should only be called for actual records. This a regression from earlier versions.

We will start working on these issues and both fixes will be available in the next service pack release due next week. As a token of gratitude for your involvement your Telerik points have been updated.

All the best,
Tsvetomir Tsonev
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
Pedro Cordero
Top achievements
Rank 1
answered on 06 Apr 2010, 06:24 PM
Thanks! Great control I've been customizing it a bit to fit my application logic so I thought I'd share some of the things I found.

Another possible issue:

With client-side binding and the Advanced Form template you provide (q1 2010 version) the "reset exceptions" button is never rendered client side:

        private void UpdateResetExceptionsVisibility() 
        { 
            ResetExceptions.Visible = false
            RecurrenceRule rrule; 
            if (RecurrenceRule.TryParse(Appointment.RecurrenceRule, out rrule)) 
            { 
               ResetExceptions.Visible = rrule.Exceptions.Count > 0; 
            } 
        } 

this always results to false with client side so the js "_initalizeResetExceptionsClientMode" function never finds the button to update it's appearance on the client.
0
T. Tsonev
Telerik team
answered on 09 Apr 2010, 02:44 PM
Hi Pedro,

Thank you for reporting this as well. We've fixed it and updated your Telerik points.

Kind regards,
Tsvetomir Tsonev
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
Pedro Cordero
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Pedro Cordero
Top achievements
Rank 1
Share this question
or