import { Component, inject, signal, ChangeDetectionStrategy } from '@angular/core';
import {
ActivateEvent,
DatatableComponent,
TableColumn
} from 'projects/swimlane/ngx-datatable/src/public-api';
import { Employee } from '../data.model';
import { DataService } from '../data.service';
@Component({
selector: 'multi-row-selection-demo',
imports: [DatatableComponent],
changeDetection: ChangeDetectionStrategy.Eager,
template: `
Multi Row Selection
Source
This demonstrates multi selection table, use CTRL or SHIFT click to select multiple
items.
Selections
@for (sel of selected(); track sel) {
-
{{ sel.name }}
} @empty {
- No Selections
}
`
})
export class MultiRowSelectionComponent {
readonly rows = signal([]);
readonly selected = signal([]);
columns: TableColumn[] = [{ prop: 'name' }, { name: 'Company' }, { name: 'Gender' }];
private dataService = inject(DataService);
constructor() {
this.dataService.load('company.json').subscribe(data => this.rows.set(data));
}
onActivate(event: ActivateEvent) {
// eslint-disable-next-line no-console
console.log('Activate Event', event);
}
}