import { Component, Input, ChangeDetectionStrategy, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Component({
selector: 'app-synced-grids',
template: `
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None, //example css, I actually have this on the "app-my-data-grid" referenced above
styles: [`
app-my-data-grid .hide-scrollbar > * {
margin-right: -7px; /* I simply have the grids slightly overlap to hide the extra scrollbars */
}
`]
})
export class ExampleSyncedGridsComponent implements OnChanges {
@Input() dataSet: any[]; //your data set type
public dataChange$ = new BehaviorSubject(true);
constructor() { }
ngOnChanges(changes: SimpleChanges): void {
if (changes["dataSet"] && this.dataSet?.length > 0) {
this.dataChange$.next(true);
}
}
}