我正在寻找一种方法来提取排序数据并将其保存在 mat-table 的
sortedData
的 dataSource
下,以便将其保存到 CSV 文件。通过将过滤器和分页应用于数据源
this.dataSource.filterPredicate; this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort
除了这个我找不到任何可行的解决方案
this.dataSource.connect().subscribe((data) => (this.sortedData = data))
但是在应用 MatPaginator 时,此解决方案返回的数据仅限于单页
this.sortedData = this.dataSource.sortData(this.dataSource.data, this.dataSource.sort)
返回所有忽略过滤的数据。
有什么想法如何从数据源获取所有排序和过滤的数据(所有页面的数据)?
您可以使用过滤数据:
已与过滤字符串匹配的过滤后的数据集, 或所有数据(如果没有过滤器)。
const sortedData = this.dataSource.sortData(this.dataSource.filteredData, this.dataSource.sort)