Declined
Last Updated: 27 May 2021 08:53 by ADMIN
Mauro
Created on: 16 Feb 2017 12:53
Category: Scheduler
Type: Feature Request
1
getting expanded appointmens in SchedulerProviderBase
In a RadScheduler with a custom provider (inheriting from SchedulerProviderBase), there is no way to get "expanded" appointments (i.e. masters plus occurrences minus exceptions). 

I devised a solution (as suggested in http://www.telerik.com/forums/scheduler-exporting-a-range-of-appointments), using the Occurrences property of RecurrenceRule:

        public IEnumerable<Appointment> GetExpandedAppointments(RadScheduler owner, DateTime start, DateTime end)
        {
            var result = new List<Appointment>();

            foreach (Appointment a in this.GetAppointments(owner))
            {
                // see http://www.telerik.com/forums/scheduler-exporting-a-range-of-appointments
                if (a.RecurrenceState == RecurrenceState.Master)
                {
                    RecurrenceRule parsedRule;
                    RecurrenceRule.TryParse(a.RecurrenceRule, out parsedRule);
                    parsedRule.SetEffectiveRange(start, end);

                    int nc = 0;
                    foreach (DateTime occurrence in parsedRule.Occurrences)
                    {
                        Appointment app = a.Clone();
                        app.ID = a.ID + "_" + ++nc;
                        app.Start = occurrence;
                        app.End = occurrence.Add(a.Duration);
                        app.RecurrenceRule = null;
                        app.RecurrenceParentID = a.ID;
                        app.RecurrenceState = RecurrenceState.Occurrence;
                        result.Add(app);
                    }
                }
                else if (a.RecurrenceState != RecurrenceState.Occurrence)
                {
                    result.Add(a);
                }
            }

            return result;
        }
    }

I think this functionality can be part of SchedulerProviderBase, there is no custom logic.

Thanks

Regards

Mauro
1 comment
ADMIN
Peter Milchev
Posted on: 27 May 2021 08:53

Hello Mauro,

Thank you for sharing your solution with the community. 

The Scheduler provider needs to provide only the Master, Non-recurring and Exception appointments to the Scheduler, and then the Scheduler will expand the appointment when, and if, it is necessary, based on its settings.

With that said, I would have to decline the request as the SchedulerProviderBase does not need expanding the appointments at all, hence no need to add functionality that is not for this class.

On the other hand, the SchedulerProviderBase is an abstract class, so you would need to inherit it anyway. In your custom class, you can easily plug the shared implementation should it be necessary.

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.