Working days in TypeScript Scheduler control

18 Nov 20184 minutes to read

The Scheduler can be customized on various aspects and inherits almost all calendar-specific features, including options to:

  • Set custom time range display on Scheduler
  • Set different working hours
  • Set different working days
  • Set different first day of week
  • Show or hide weekend days
  • Show the week number

Set working days

By default, Scheduler considers the week days from Monday to Friday as Working days and therefore defaults to [1,2,3,4,5] - where 1 represents Monday, 2 represents Tuesday and so on. The days which are not defined in this working days collection are considered as non-working days. When weekend days are set to hide from Scheduler, all non-working days are also hidden from the layout.

The Work week and Timeline Work week views displays exactly the defined working days on Scheduler layout, whereas other views displays all the days and simply differentiates the non-working days on UI with inactive cell color.

Working business hours depicted on Scheduler are valid only on these specified working days.

The following example code shows how to set the Scheduler to display Monday, Wednesday and Friday as working days of a week.

Hiding weekend days

The showWeekend property is used to either show or hide the weekend days of a week and it is not applicable on Work week view (as non-working days are usually not displayed on work week view). By default, it is set to true. The days which are not a part of the working days collection of a Scheduler are usually considered as non-working or weekend days.

Here, the working days are defined as [1, 3, 4, 5] on Scheduler and therefore the remaining days (0, 2, 6 – Sunday, Tuesday and Saturday) are considered as non-working or weekend days and will be hidden from all the views when showWeekend property is set to false.

Show week numbers

The week number count can be displayed in the header bar of the Scheduler by setting true to showWeekNumber property. By default, this property is set to false. In Month view, the week numbers are displayed as a first column.

The showWeekNumber property is not applicable on Timeline views, as it has the equivalent headerRows property to handle such requirement with additional customizations.

Different options in showing week numbers

By default, week numbers are shown in the Scheduler based on the first day of the year. However, the week numbers can be determined based on the following criteria.

FirstDay – The first week of the year is calculated based on the first day of the year.

FirstFourDayWeek – The first week of the year begins from the first week with four or more days.

FirstFullWeek – The first week of the year begins when meeting the first day of the week (firstDayOfWeek) and the first day of the year.

For more details refer to this link

Note: Enable the showWeekNumber property to configure the weekRule property. Also, the weekRule property depends on the value of the firstDayOfWeek property.

Set working hours

Working hours indicates the work hour limit within the Scheduler, which is visually highlighted with an active color on work cells. The working hours can be set on Scheduler using the workHours property which is of object type and includes the following sub-options,

  • highlight – Enables or disables the highlighting of work hours.
  • start - sets the start time of the working/business hour of a day.
  • end - sets the end time limit of the working/business hour of a day.

Scheduler displaying custom hours

The Scheduler layout can display specific time durations by hiding the unwanted hours. To do so, set the start and end hour for the Scheduler using the startHour and endHour properties respectively.

The following code example displays the Scheduler starting from the time range 7.00 AM to 6.00 PM and the remaining hours are hidden on the UI.

Setting start day of the week

By default, the Scheduler sets Sunday as its first day of a week. To change the Scheduler’s start day of a week with different day, use the firstDayOfWeek property with the values ranging from 0 to 6.

Here, Sunday is always denoted as 0, Monday as 1 and so on.

Scroll to specific time and date

The Scheduler can be manually scrolled to a specific time on Scheduler using the scrollTo method as shown in the following code example.

How to scroll to current time on initial load

In scenarios where the Scheduler needs to load displaying the system’s current time on the currently visible viewport area, the Scheduler needs to be scrolled to a specific time based on the system’s current time, as shown in the following code example.

Refer to the JavaScript Scheduler feature tour page for its groundbreaking feature representations. Also explore our JavaScript Scheduler example to learn how to present and manipulate data.

See Also