Angular 6 Get sorted data from Material Table

微笑、不失礼 提交于 2020-01-14 19:59:27

问题


Is there any way to get the sorted data from a material table after sorts on the table have been applied? I can see "filteredData" in the table datasource but there's no "sortedData". The reason why I want the sorted data is so that I can export it in a csv file while maintaining all of the sorts applied. I've been using the built in MatSort to sort individual columns in the table.


回答1:


There is a sort data method, that you can use with either datasource.data or datasource.filteredData

    dataSource.sortData(dataSource.filteredData,dataSource.sort);


来源:https://stackoverflow.com/questions/51545489/angular-6-get-sorted-data-from-material-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!