Displaying a Custom Tooltip for Scheduler Events
Environment
Product | Progress® Kendo UI® Scheduler for Angular |
Description
How can I display a custom Tooltip component when hovering over the Scheduler events?
Solution
To display a Kendo UI for Angular Tooltip when hovering over Scheduler events:
-
Wrap the Scheduler component in a custom container with the
kendoTooltip
directive. To display the Tooltip on specific elements, set theshowOn
property tonone
and handle the HTML mouseover event.html<div kendoTooltip showOn="none" (mouseover)="showTooltip($event)"> <kendo-scheduler ... > <kendo-scheduler-day-view> </kendo-scheduler-day-view> ... </kendo-scheduler> </div>
-
To dynamically show a tooltip for the necessary elements, use the built-in
toggle
andhide
methods of the Tooltip inside themouseover
event handler.tspublic showTooltip(e): void { const element = e.target as HTMLElement; const tdHovered = element.nodeName === 'TD' && element.firstElementChild.className === 'k-task'; const titleHovered = element.className === 'k-task'; if (tdHovered || titleHovered) { const anchorElement = titleHovered ? element.parentElement : element; this.tooltipDir.toggle(anchorElement, true); } else { this.tooltipDir.hide(); } }
-
Set the
tooltipTemplate
property to provide a custom template for the content of the Tooltip. Use theeventFromElement
method of the Scheduler and find the event associated with the specified DOM element (if any).html<ng-template #template let-anchor> <span>{{ scheduler.eventFromElement(anchor.nativeElement) | json }}</span> </ng-template> <div kendoTooltip tooltipTemplate]="template"> ... </div>
-
When the view is changed, a new set of listeners are needed for the rendered events. More details about this step are available in the example below.
The following example demonstrates how to display a Tooltip for Scheduler events.