更新时间:2023-02-02 12:10:55
事实证明,我只需要连接到数据源,并存储从表中呈现的行的元素数组:
As it turned out, I just had to connect to the datasource, and store an array of elements that were the rendered rows from the table:
ngOnChanges(changes: SimpleChanges) {
this.dataSource.sort = this.sort;
this.dataSource.connect().subscribe(d => this.renderedData = d);
}
然后我可以遍历该集合:
Then I could iterate through that collection instead:
// And this performs the actual selection.
private selectRowsBetween(start, end) {
let currentIndex = 0;
this.renderedData.forEach(row => {
if (currentIndex >= start && currentIndex <= end) {
this.selection.select(row);
}
currentIndex++;
});
}