import { Component, inject, signal, ViewChild, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; import { DataTableColumnCellDirective, DataTableColumnDirective, DataTableColumnHeaderDirective, DatatableComponent, DatatableRowDetailDirective, DatatableRowDetailTemplateDirective, DetailToggleEvents, PageEvent } from 'projects/swimlane/ngx-datatable/src/public-api'; import { FullEmployee } from '../data.model'; import { DataService } from '../data.service'; @Component({ selector: 'responsive-demo', imports: [ DatatableComponent, DatatableRowDetailDirective, DatatableRowDetailTemplateDirective, DataTableColumnDirective, DataTableColumnCellDirective, DataTableColumnHeaderDirective ], template: `

Responsive Source

@let rows = this.rows();
This demo combines the features used in the Row Detail Rows demo, Flex Column demo, and the Inline Templates demo. When your browser is at 800px, the gender and age columns will be hidden and will appear in the row detail view.
`, styles: ` @media screen and (max-width: 800px) { .desktop-hidden { display: initial; } .mobile-hidden { display: none; } } @media screen and (min-width: 800px) { .desktop-hidden { display: none; } .mobile-hidden { display: initial; } } `, // eslint-disable-next-line @angular-eslint/use-component-view-encapsulation changeDetection: ChangeDetectionStrategy.Eager, encapsulation: ViewEncapsulation.None }) export class ResponsiveComponent { @ViewChild('myTable') table!: DatatableComponent; readonly rows = signal([]); expanded: any = {}; timeout: any; private dataService = inject(DataService); constructor() { this.dataService.load('100k.json').subscribe(data => this.rows.set(data)); } onPage(event: PageEvent) { clearTimeout(this.timeout); this.timeout = setTimeout(() => { // eslint-disable-next-line no-console console.log('paged!', event); }, 100); } toggleExpandRow(row: FullEmployee) { this.table.rowDetail!.toggleExpandRow(row); } onDetailToggle(event: DetailToggleEvents) { // eslint-disable-next-line no-console console.log('Detail Toggled', event); } }