import { Component, inject, signal, ChangeDetectionStrategy } from '@angular/core'; import { DataTableColumnCellDirective, DataTableColumnDirective, DatatableComponent } from 'projects/swimlane/ngx-datatable/src/public-api'; import { Employee } from '../data.model'; import { DataService } from '../data.service'; @Component({ selector: 'vert-dynamic-scrolling-demo', imports: [DatatableComponent, DataTableColumnDirective, DataTableColumnCellDirective], changeDetection: ChangeDetectionStrategy.Eager, template: `

Vert Dynamic Scrolling Source

@if (editing[rowIndex + '-name']) { } @else { {{ value }} } @if (!editing[rowIndex + '-gender']) { {{ value }} } @else { } {{ value }}
` }) export class VertDynamicScrollingComponent { editing: Record = {}; readonly rows = signal([]); private dataService = inject(DataService); constructor() { this.dataService.load('company.json').subscribe(data => { this.rows.set(data.slice(0, 5)); }); } updateValue(event: Event, cell: 'gender' | 'name', rowIndex: number) { this.editing[rowIndex + '-' + cell] = false; const rows = this.rows(); rows[rowIndex][cell] = (event.target as HTMLInputElement | HTMLSelectElement).value; this.rows.set([...rows]); } }