Add days off to scheduler

1 Answer 189 Views
Scheduler
Roel
Top achievements
Rank 1
Iron
Veteran
Roel asked on 18 Jun 2021, 08:13 AM

At the moment we are using Kendo UI Scheduler for jQuery. We like to add days off. We implemented business hours & weekends and that is working fine. We like to do the same but only on certain dates at certain hours. I found already something on the internet but I like to use standard functionality. If there is no standard for this, I like to add it as a wish.

Roel

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 23 Jun 2021, 06:58 AM

Hi Roel,

If you need to prevent adding events in specific days, you could subscribe to the add event of the Scheduler. In the event handler you could check the day to which the user is trying to add a new event and prevent the default behavior if needed.

 add: function(e) {    
          if(e.event.start.getDate() == 3 && e.event.start.getMonth() == 5 ||
             e.event.end.getDate() == 3 && e.event.end.getMonth() == 5)
          { 
            e.preventDefault()
            alert("This is a non working day")
          }
        }

In case you need to change the background color of the slots for the respective date you could use the dataBound event. In the event handler you could use the slotByElement method and change for example the background color of the slot:

function onDataBound(e) {
        var scheduler = e.sender;
        var slots = $('.k-scheduler-content td[role=gridcell]');

        for (var i = 0; i < slots.length; i += 1) {
          var currentSlot = $(slots[i]);
          var slotData = scheduler.slotByElement(currentSlot);

          if (slotData.startDate.getDate() === new Date("2013/6/3").getDate() &&
              slotData.startDate.getMonth() === new Date("2013/6/3").getMonth()
             ) { 
            currentSlot.css('background-color', 'lightgray');            
          }
        }
      }

Here is a Dojo example where the described above is demonstrated.

I would also suggest to take a look at the

- "Mark holidays in month view" knowledge base article

- the Scheduler Restrictions demo which demonstrates how to prevent moving/dragging events to the marked slots

In case the provided suggestion does not resolve the issue, you could log a Feature request for support setting certain days as non-working/holiday in our official Feedback Portal describing the requirements in details. Based on the community interest in the feature, we may consider its implementation in the future. 

Regards,
Neli
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
Roel
Top achievements
Rank 1
Iron
Veteran
Answers by
Neli
Telerik team
Share this question
or