Get date range of current view in scheduler

1 Answer 344 Views
Scheduler
Shivam
Top achievements
Rank 1
Shivam asked on 26 Feb 2023, 02:21 PM

Hi Team,

I want to get the date range of the current view whenever the scheduler component loads and whenever the user changes the view or changes the date by the navigation button (next, prev, date picker). I need to know the start and end date which is visible on the scheduler. I am able to know the view name by using onViewChange callback and default date by using onDateChange which is giving me the default selected date but I want the whole range (start to end), I am using class-based components.

Scenario: Currently selected view is the month view and the default date is in the month of Feb 2023 so I need something which gives me the start date as Jan 29, 2023, and the end date as March 04, 2023.

Just like In the Jquery version of the scheduler, we get the required information by using the following function:

function scheduler_view_range(e) {
        var view = e.sender.view();

        // The view has:
        // A startDate method which returns the start date of the view.
        // An endDate method which returns the end date of the view.

        $(".console").append("<p>" + kendo.format("view:: start: {0:d}; end: {1:d};", view.startDate(), view.endDate()) + "</p>");
    }

1 Answer, 1 is accepted

Sort by
1
Wissam
Telerik team
answered on 28 Feb 2023, 11:55 AM

Hello, Shivam,

Each view has an internal `dateRange` method (ex: WeekView's method is `weekViewDateRange` ) that can return the current date range for the view based on the selected date. The method accepts the date, number of days, and intl ( `const intl = useInternationalization()` ) as arguments and returns the `start` and `end` date values.

I prepared an example showcasing how you can use it to get the date range of the current view:

Please check it and let us know if you have any further questions.

Regards,
Wissam
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/.

John
Top achievements
Rank 1
commented on 08 Feb 2024, 11:00 AM

Hi Dear,

 

Just wondering do you know how to change the date format on KendoUI react Scheduler ? I am want dd/mm/yyyy not mm/dd/yyyyy. I couldn't find it on how to do it on Kendo Documentation.

Wissam
Telerik team
commented on 09 Feb 2024, 03:53 PM

Hi, John,

You can achieve this by wrapping the Scheduler component with the `CalendarPropsContext` from the `@progress/kendo-react-dateinputs` package. This approach is needed because the properties of the DatePicker are not exposed to the Scheduler componets, and props context in this case is a solution that allows modifying the properies.

We have an example where the calendar props are modified for the Grid component. You can apply the same approach from the Scheduler but using the props context of the datepicker instead:

You can view all the available dateinput contexts here:

In addition, you can change the DatePicker's format using its format property:

I hope this helps.

Regards,
Wissam
Progress Telerik
Tags
Scheduler
Asked by
Shivam
Top achievements
Rank 1
Answers by
Wissam
Telerik team
Share this question
or