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

How to retrieve scheduler current date range in C#?

7 Answers 710 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ther Pick
Top achievements
Rank 1
Ther Pick asked on 29 Jan 2018, 07:16 AM

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.

7 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 30 Jan 2018, 04:47 PM
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.
0
Ther Pick
Top achievements
Rank 1
answered on 01 Feb 2018, 03:37 AM

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.

0
Neli
Telerik team
answered on 02 Feb 2018, 03:20 PM
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.
0
Ther Pick
Top achievements
Rank 1
answered on 12 Feb 2018, 09:48 AM

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. date range?

Thank you very much.

 

0
Neli
Telerik team
answered on 13 Feb 2018, 03:08 PM
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.
0
Sean
Top achievements
Rank 1
answered on 02 Oct 2020, 02:32 PM

Hi Neli,

Is this still un-solved or anything we can do to generate the recurrence dates beyond the front-view? Please suggest. Thanks

Regards,

0
Neli
Telerik team
answered on 06 Oct 2020, 09:14 AM

Hi Sean,

The occurrences of the recurring events in the Scheduler could be retrieved through the occurrenceInRange method. As it is written in my previous replies the result is scoped to the currently displayed view. So, the specified range should be within the view's time range. I am afraid that I could not suggest a workaround in order to retrieve all the occurrences that are not part of the currently displayed view. 

If you think, that such functionality would add value to the widget, I would suggest you log your idea as a feature request on our Feedback portal. This way the other users could vote for the idea. if the community shows interest in having such a feature, we will consider enhancing the component.

Regards,
Neli
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Scheduler
Asked by
Ther Pick
Top achievements
Rank 1
Answers by
Neli
Telerik team
Ther Pick
Top achievements
Rank 1
Sean
Top achievements
Rank 1
Share this question
or