Setting Break time in Kendo UI Scheduler

0 Answers 91 Views
Scheduler
Pankaj
Top achievements
Rank 1
Iron
Iron
Pankaj asked on 18 Jul 2023, 06:28 PM | edited on 18 Jul 2023, 06:35 PM

Hi

I am trying to set break time like lunch,Tea time to restrict appointment for particular time. All works fine when I Set Major Tick to 60, but its not working properly when Setting Major ticks to 30.

This setting not apply between 3:30PM to 3:45PM when set MajorTick:30 (PFA the same)

My Code for this is as follows:- 


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);
                                    var items = '';
                                  
                                    $.each(BreakTimeList, function (i, item) {
                                       //Trying to set it 3:00PM to 3:30PM and 3:30PM to 4:00 PM 
                                     //But this setting not apply between 3:30PM to 3:45PM when MajorTick set to 30

                                        if ((slotData.startDate.getHours() >= 3 && slotData.startDate.getMinutes() >= 00)
                                            && (slotData.endDate.getHours() <= 3 && slotData.endDate.getMinutes() <= 30)) {
                                            currentSlot.html('<i class="fa fa-stopwatch"></i>');
                                       
                                        }
                                    });
                                }
                            }

Regards 

Pankaj

Nikolay
Telerik team
commented on 21 Jul 2023, 02:23 PM

Hi Pankaj,

Could you please share a runnable Dojo demo where the problem is replicated? This will help me fully understand the case and allow me to investigate further.

Regards,

Nikolay

Pankaj
Top achievements
Rank 1
Iron
Iron
commented on 27 Jul 2023, 07:08 PM

Hi Nikolay

Here is the Dojo Demo where problem can be easily identified. here OnDataBound and Edit events is not working as expected.

Regards

Pankaj

Nikolay
Telerik team
commented on 01 Aug 2023, 12:24 PM

Hi Pankaj,

Thank you for the Dojo example.

To have the slot of 1:45 PM to 2:00 PM disabled for editing you need to make a correct check of the start and end time slots:

     edit: function(e){ 
          if(e.event.start.getTime()== Date.parse('Thu Jun 06 2013 13:45:00') && e.event.end.getTime() == Date.parse('Thu Jun 06 2013 14:00:00')){
            e.preventDefault()
            alert('Lounch time!')
          }
        },

Dojo demo: https://dojo.telerik.com/eHOFoPEc

Regards,

Nikolay

 

Pankaj
Top achievements
Rank 1
Iron
Iron
commented on 06 Aug 2023, 04:47 PM | edited

Hi Nikolay,

Thanks you for your response. I can't put date here for caparison because i want it for every day not for single day.

and this is not working when MajorTick is set to 60 for particular day and time slot 1 to 2 PM (PFA the same)


majorTick: 60,
        edit: function(e){ 
          if(e.event.start.getTime()== Date.parse('Thu Jun 06 2013 13:00:00') && e.event.end.getTime() == Date.parse('Thu Jun 06 2013 14:00:00')){
            e.preventDefault()
            alert('Lounch time!')
          }

Regards

Pankaj

Pankaj
Top achievements
Rank 1
Iron
Iron
commented on 09 Aug 2023, 01:29 PM

Hi Nikolay,

Request you to please provide me solution for this. 

Regards

Pankaj

Neli
Telerik team
commented on 10 Aug 2023, 05:02 AM

Hi Pankaj,

Could you please try to extend the if conditions and check not only the hour but also the minutes of the event in the edit event handler? Below is an example:

edit: function(e){  
          if( (e.event.start.getHours() >= 13 && e.event.end.getHours() <= 14 
             && e.event.start.getMinutes() > 30 && e.event.end.getMinutes() < 45) ||
            	(e.event.start.getHours() >= 13 && e.event.end.getHours() <= 14 
             && e.event.start.getMinutes() == 30 && e.event.end.getMinutes() == 0)
            ){
            e.preventDefault()
            alert('Lounch time!')
          }
        },

Here is the modified Dojo example.

Regards,

Neli

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
Pankaj
Top achievements
Rank 1
Iron
Iron
Share this question
or