Slot Selection Handler interferes with single Event Click Handler in Scheduler

1 Answer 104 Views
Scheduler
Bryan
Top achievements
Rank 1
Bryan asked on 29 Apr 2022, 03:22 AM

I*m using both the slot selection and a single click event handler in the same scheduler component:

<kendo-scheduler
            [kendoSchedulerBinding]="allEvents$ | async"
            (eventClick)="eventClickHandler($event)"
            kendoSchedulerSlotSelectable
            (slotSelectionChange)="onTimeSlotSelectionChange($event)"
            [resources]="resources"
            [selectedDate]="selectedDate"
            [(selectedViewIndex)]="selectedViewIndex"
            [eventClass]="getEventClass"
            (dateChange)="onDateChange($event)"
            [loading]="loading"
            showWorkHours="true"
            workDayStart="{{formatDateAsTime(businessStartDate)}}"
            workDayEnd="{{formatDateAsTime(businessEndDate)}}"
            style="height: 1050;"
        >
            <ng-template
                kendoSchedulerEventTemplate
                let-event="event"
                let-resources="resources"
            >
                <span class="{{ resources[0].customCssClass }}">{{formatEventText(event, resources[0])}}</span>
            </ng-template>
            <kendo-scheduler-day-view [eventHeight]="300"></kendo-scheduler-day-view>
            <kendo-scheduler-week-view></kendo-scheduler-week-view>
            <kendo-scheduler-month-view></kendo-scheduler-month-view>
    </kendo-scheduler>

 

I would expect when clicking on an existing event in the scheduler, only the eventClick handler would fire.  But both the eventClick handler AND the slotSelectionChange handler are firing in that case.  How do I prevent that?

1 Answer, 1 is accepted

Sort by
1
Accepted
Ivan
Telerik team
answered on 03 May 2022, 12:21 PM

Hi Bryan,

In deed it can be very inconvenient, but one can use some async setting of mutex variable in order to differentiate those - like in this stackblitz sample . Here slotSelectionChange execution is delayed by 20ms, while eventClick sets eventClicked = true to block slotSelectionChange and then schedules timeout function after 30ms to set it again to false in order to unblock for next selection change.

Please let us know it this approach will solve your case.

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

Bryan
Top achievements
Rank 1
commented on 03 May 2022, 01:49 PM

I think this will work.  Thanks for your help!
Tags
Scheduler
Asked by
Bryan
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or