# Displaying a Custom Tooltip for Scheduler Events

## Environment

<table>
	<tbody>
		<tr>
			<td>Product</td>
			<td>Progress® Kendo UI® Scheduler for Angular</td>
		</tr>
	</tbody>
</table>

## Description

How can I display a custom [Tooltip](https://www.telerik.com/kendo-angular-ui/components/tooltips/tooltip) component when hovering over the Scheduler events?

## Solution

To display a Kendo UI for Angular Tooltip when hovering over Scheduler events:

1. Wrap the Scheduler component in a custom container with the `kendoTooltip` directive. To display the Tooltip on specific elements, set the [`showOn`](https://www.telerik.com/kendo-angular-ui/components/tooltips/api/tooltipdirective#showon) property to `none` and handle the HTML [mouseover](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event) event.

   ```html
   <div
       kendoTooltip
       showOn="none"
       (mouseover)="showTooltip($event)">
       <kendo-scheduler ... >
           <kendo-scheduler-day-view> </kendo-scheduler-day-view>
           ...
       </kendo-scheduler>
   </div>
   ```

2. To dynamically show a tooltip for the necessary elements, use the built-in [`toggle`](https://www.telerik.com/kendo-angular-ui/components/tooltips/api/tooltipdirective#toggle) and [`hide`](https://www.telerik.com/kendo-angular-ui/components/tooltips/api/tooltipdirective#hide) methods of the Tooltip inside the `mouseover` event handler.

   ```ts
   public 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();
       }
   }
   ```

3. [Set the `tooltipTemplate` property](https://www.telerik.com/kendo-angular-ui/components/tooltips/tooltip/templates) to provide a custom template for the content of the Tooltip. Use the [`eventFromElement`](https://www.telerik.com/kendo-angular-ui/components/scheduler/api/schedulercomponent#eventfromelement) 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>
   ```

4. 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.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/scheduler-custom-tooltip/source.txt)
