-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(table): remove clipcell and width calculation (#1162)
- Loading branch information
1 parent
4e1b0d7
commit f4ac95d
Showing
1 changed file
with
2 additions
and
26 deletions.
There are no files selected for viewing
28 changes: 2 additions & 26 deletions
28
projects/ng-aquila/src/table/resizing/table-cell-clip.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,9 @@ | ||
import { AfterViewInit, Directive, ElementRef, Renderer2 } from '@angular/core'; | ||
import { Directive } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: 'table[nxTableCellClip]', | ||
host: { | ||
'[style.table-layout]': '"fixed"', | ||
}, | ||
}) | ||
export class NxTableCellClipDirective implements AfterViewInit { | ||
constructor( | ||
private elementRef: ElementRef, | ||
private renderer: Renderer2, | ||
) {} | ||
|
||
clipCell(cell: any) { | ||
this.renderer.setStyle(cell, 'white-space', 'nowrap'); | ||
this.renderer.setStyle(cell, 'overflow', 'hidden'); | ||
this.renderer.setStyle(cell, 'text-overflow', 'ellipsis'); | ||
} | ||
|
||
ngAfterViewInit() { | ||
const tds = this.elementRef.nativeElement.querySelectorAll('td'); | ||
tds.forEach((cell: any) => { | ||
this.clipCell(cell); | ||
}); | ||
const ths = this.elementRef.nativeElement.querySelectorAll('th'); | ||
ths.forEach((cell: any) => { | ||
this.clipCell(cell); | ||
const width = cell?.getBoundingClientRect().width; | ||
this.renderer.setStyle(cell, 'width', `${width}px`); | ||
}); | ||
} | ||
} | ||
export class NxTableCellClipDirective {} |