Scheduler MVC Recurrence occurrencesInRange not returning all values

2 posts, 0 answers
  1. ICT
    ICT avatar
    6 posts
    Member since:
    Oct 2017

    Posted 29 Nov 2017 Link to this post

    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

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1201 posts

    Posted 01 Dec 2017 Link to this post

    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.
Back to Top