1 import {Component, Input, OnInit, AfterViewInit,
2 TemplateRef, ElementRef, AfterContentChecked} from '@angular/core';
3 import {GridContext, GridColumn, GridRowSelector,
4 GridColumnSet, GridDataSource} from './grid';
7 selector: 'eg-grid-body-cell',
8 templateUrl: './grid-body-cell.component.html'
11 export class GridBodyCellComponent implements OnInit, AfterContentChecked {
13 @Input() context: GridContext;
15 @Input() column: GridColumn;
18 tooltipContent: string | TemplateRef<any>;
21 private elm: ElementRef
26 ngAfterContentChecked() {
30 // Returns true if the contents of this cell exceed the
31 // boundaries of its container.
32 cellOverflows(): boolean {
33 let node = this.elm.nativeElement;
35 node = node.parentNode;
37 node.scrollHeight > node.clientHeight ||
38 node.scrollWidth > node.clientWidth
44 // Tooltips are only applied to cells whose contents exceed
46 // Applying an empty string value prevents a tooltip from rendering.
48 if (this.cellOverflows()) {
49 this.tooltipContent = this.column.cellTemplate ||
50 this.context.getRowColumnValue(this.row, this.column);
53 this.tooltipContent = '';