How to retrieve scheduler current date range in C#?

6 posts, 0 answers
  1. Ther Pick
    Ther Pick avatar
    5 posts
    Member since:
    Nov 2017

    Posted 29 Jan Link to this post

    Hi,

    May I know how to retrieve Kendo Scheduler current date range in C# code?

    I need to date range so I can populate the date in another detail table.

    Thank you.

  2. Neli
    Admin
    Neli avatar
    139 posts

    Posted 30 Jan Link to this post

    Hi,

    The following article demonstrates how to retrieve the current date range.

    An example on how to subscribe to the Scheduler events in MVC project is described in the following demo.

    I hope that the provided information will be helpful. 

    Regards,
    Neli
    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.
  3. Ther Pick
    Ther Pick avatar
    5 posts
    Member since:
    Nov 2017

    Posted 31 Jan in reply to Neli Link to this post

    Hi Neli,

    Thank you for your reply. It is helpful but I have other similar questions here.

    How about I want to get all the date & time (calendar events) for the recurring schedule? 

    Besides that, is it any other ways to get all the date & time directly from C# without subscribing to the Scheduler javascript event? For eg: a helper method to generate the date & time using the record in DB? I need to use all the date & time information to generate data in another detail table in C#.

     

    Thank you.

  4. Neli
    Admin
    Neli avatar
    139 posts

    Posted 02 Feb Link to this post

    Hello,

    If I understand correctly, you need to retrieve the date and time of all the recurring events.

    In case you need to retrieve the data about all initial recurring events, you can use DataSource data() method
    var scheduler = $('#scheduler').data('kendoScheduler');
    var data = scheduler.dataSource.data();

    Next you can filter all the events, by checking their recurrence rule:
    var recurring = data.filter(e => e.recurrenceRule != null && e.recurrenceRule != "");

    Then, you can access the start and end time of all the events
    recurring.forEach(function(e){           
    console.log('START: ' + e.start + ' END: ' + e.end);
    })

    In the linked Dojo example the start and end time of all recurring events will be console logged on button click. The approach in MVC project will be the same. 


    In case you need to retrieve the data about all occurrences of the events, you can use the occurrencesInRange method. This method returns a list of the event occurrences for specified range. You will need to filter the events, by checking if they have recurrenceRule or recurrenceId. Note, that the result of this method is scoped to the currently displayed view.
    var events = scheduler.occurrencesInRange(new Date("2013/6/5"), new Date("2013/6/10")); 
    var ocurrencies = events.filter(e => e.recurrenceRule != null &&
                                             e.recurrenceRule != undefined ||
                                             e.recurrenceId);

    In the Dojo example linked here, the recurring event occurrences are console logged. 

    I am afraid, that the data about the recurring events could not be retrieved directly from the C# code. In order to get the data regarding the recurring event occurrencies you will need to do it client-side, as it is described above.

    Regards,
    Neli
    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.
  5. Ther Pick
    Ther Pick avatar
    5 posts
    Member since:
    Nov 2017

    Posted 12 Feb in reply to Neli Link to this post

    Hi Neli,

    The occurrencesInRange method is helpful. But as what you wrote, it is scoped to currently displayed view only. 

    Any other methods that will return beyond the scope? For e.g. 1 year date range?

    Thank you very much.

     

  6. Neli
    Admin
    Neli avatar
    139 posts

    Posted 13 Feb Link to this post

    Hello Ther Pick,

    I am afraid that Scheduler API does not provide methods to check all occurrences of recurring event, that are not part of the currently displayed view.
    I would suggest you to log the idea as a feature request in our Feedback portal. Based on the support it receives from the community, we will decide on whether to proceed with its implementation or not. 

    Regards,
    Neli
    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