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

Changing BusinessHours dynamically lead to an error in the timelineMonth View

1 Answer 218 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
K.Ramadan
Top achievements
Rank 2
Veteran
K.Ramadan asked on 06 Jan 2021, 03:16 PM

Hello,

 

I'm trying to change the time dynamically for each day and each employee individual.

I've achieved that for all Views except the timlineMonth!

So every time I change the business hours dynamically, then the timelineMonth View does not work and one of these errors appear in the chrome devtools

kendo.all.js:113735 Uncaught TypeError: Cannot read property 'children' of undefined

OR

Uncaught TypeError: Cannot read property 'end' of undefined

 

I took the first Dojo example from you :

https://www.telerik.com/forums/how-to-set-business-hours-day-wise#6omvyHlQFkWOQVe1OTWdnw

 

and edited it to reproduce the issue:

https://dojo.telerik.com/aqekoJAG

 

steps to reproduce the issue:

1- change the time from the droplist (select) above the scheduler

2- change the view to timelineMonth

3- open debugger (e.g. devtools console) to see one of the error that I mentioned above 

 

 Thanks in advance

 

K.Ramadan

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 08 Jan 2021, 01:55 PM

Hello,

The reason for the observed error is that the showWorkHours configuration is only available with the "day" and "week" views, as documented here https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler/configuration/showworkhours. In order to change the startTime and endTime of the "timelineMonth" view, however, the Scheduler will need to be destroyed and reinitialized again, as explained in this forum thread:

https://www.telerik.com/forums/kendo-scheduler-change-start-time-when-the-date-changes-in-navigation-bar#bgw1-SQYWEKaqwSPx8xtIQ

Based on the above I have modified the provided example, by adding a check if the current view is a "timelineMonth" view and if so the Scheduler is destroyed and re-created with the required configuration:

        if(scheduler.viewName() === "timelineMonth"){
          var options = scheduler.options;

          scheduler.destroy();
          options.showWorkHours = false;

          options.views = [
            "day",
            "week",
            "timelineWeek",
            "month",
            { type: "timelineMonth", selected: true, startTime:start,endTime:end  },
            "agenda"
          ];
          $("#scheduler").empty().kendoScheduler(options);


        } else {
          //set the scheduler options
          scheduler.options.workDayStart = start;
          scheduler.options.workDayEnd = end;
          //update the view by re-selecting it
          scheduler.view(scheduler.view().name);
        }

Here is a runnable example of the above. I hope this helps.

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

Tags
Scheduler
Asked by
K.Ramadan
Top achievements
Rank 2
Veteran
Answers by
Aleksandar
Telerik team
Share this question
or