Skip to content

Commit

Permalink
fix(table): remove clipcell and width calculation (#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and GitHub Enterprise committed Apr 11, 2024
1 parent 4e1b0d7 commit f4ac95d
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions projects/ng-aquila/src/table/resizing/table-cell-clip.directive.ts
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 {}

0 comments on commit f4ac95d

Please sign in to comment.