我有一个材料表。 我用输入将数据源设置在内存中
我正在寻找分页结束时表准备好时发出的事件,因为我必须在顶部滚动一行。
如果我在设置数据源时尝试搜索行(带有getElementById和行的ID),则由于表尚未准备好而找不到行。
材料表中有一个事件吗?
export class MyComponent implements AfterViewInit {
@Input() set myDataSource(value: datasource[]) {
if (value) {
this.dataSource.data = value;
this.scrollRow(this.activatedRoute);
}
}
dataSource = new MatTableDataSource<datasource>();
scrollRow(route: ActivatedRoute) {
// search id from routing
const child = route.firstChild as ActivatedRoute;
const id = +child.snapshot.params.id
(document.getElementById(id.toString()) as HTMLElement).scrollIntoView(true);
}
}