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

Scheduler MVC Recurrence occurrencesInRange not returning all values

1 Answer 141 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
ICT
Top achievements
Rank 1
ICT asked on 30 Nov 2017, 03:40 AM

Hi,

I'm trying to determine whether there is a clash with an occupied time slot when creating an event with a recurrence. I am able to make this determination when dealing with a daily recurrence. When I try using weekly recurrence only the first occurrence is returned and nothing else when using the occurrencesInRange method.

 

Here is my code:

function scheduler_save(e) {

        var scheduler = $("#scheduler").getKendoScheduler();
    if (e.event.recurrenceRule != 'undefined' && e.event.recurrenceRule != '') {
            
                var nextOccurrence = e.event.expand(e.event.start, new Date(2999, 0, 1), "Etc/UTC");
                for (var idx = 0, length = nextOccurrence.length; idx < length; idx++) {
                   var occurrences = scheduler.occurrencesInRange(nextOccurrence[idx].start, nextOccurrence[idx].end);
                    
                    if (occurrences.length > 0) {
                        msg += nextOccurrence[idx].start + '\n';
                        
                    }
                }
                if (nextOccurrence.length > 0) {
                    
                    alert(msg);
                }
                

        }
        else {
            if (!checkAvailability(e.event.start, e.event.end, e.event, e.event.resources)) {

                e.preventDefault();
            }

        }
}

Would anyone be able to point me in the right direction.

 

Thank you.

 

Phil

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 01 Dec 2017, 12:27 PM
Hello Phil,

The occurrencesInRange() method is scoped to the currently displayed view. Therefore, the specified range should be within the view's time range. This means that if on a Scheduler Week view, for example, only the occurrences on the current view will be checked and retrieved. The method would not return an event, if it is scheduled within the next week for example.

Therefore, I am afraid, that the Scheduler does not expose the API needed to check any possible occurrence of a recurring event. If you think, that such functionality would add value to the widget, I would suggest you to log your idea as feature request on our Feedback portal.

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
ICT
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or