New to Kendo UI for Angular? Start a free 30-day trial
Rendering Tooltips for Spreadsheet Cells
Environment
Product | Progress® Kendo UI for Angular Tooltip | Progress® Kendo UI for Angular Spreadsheet |
Description
How can I show the content of a Kendo UI for Angular Spreadsheet cell in a tooltip which will be displayed when the user hovers over that cell?
Solution
-
Use the Tooltip template to display the content of its
anchor
elements.html<ng-template #template let-anchor> <span>{{ anchor.nativeElement.innerText }}</span> </ng-template>
-
Wrap the Spreadsheet component inside the
kendoTooltip
directive. SetshowOn
tonone
and handle themouseover
event to show the Tooltip in specific conditions.html<div kendoTooltip showOn="none" [tooltipTemplate]="template" filter="div .k-spreadsheet-cell.k-vertical-align-bottom" (mouseover)="showTooltip($event)" > <kendo-spreadsheet></kendo-spreadsheet> </div>
-
Use the
toggle
andhide
methods to change the visibility of the Tooltip programmatically. Show a tooltip when hovering over Spreadsheet cells.tspublic showTooltip(e: MouseEvent): void { const element = e.target as HTMLElement; if ( element.nodeName === 'DIV' && (element.classList.contains('k-spreadsheet-cell') || element.classList.contains('k-vertical-align-bottom')) ) { this.tooltipDir?.toggle(element); } else { this.tooltipDir?.hide(); } }
The following example demonstrates the full implementation of the suggested approach.
Change Theme
Theme
Loading ...