问题描述
我正在使用 Ignite 用户界面。因为我使用的是 Igx 网格,所以我可以使用 IgxExcelExporterService
导出所有数据的 excel,但我想使用 onRowSelectionChange
的 igx grid
方法仅导出选定的数据。有没有办法igx-grid
支持这个功能?
解决方法
您可以使用 Excel 导出器服务:
this.excelExportService.exportData
(this.data,..).
继续将 data array
传递给服务。如何用选定的行数据填充数据数组?您可以在此处找到用于引导您的 POC 的代码片段:
实际代码:
public clicked() {
let selectedRows = this.grid1.selectedRows;
for (let rowIndex of selectedRows) {
let rowData = this.grid1.getRowByIndex(rowIndex).rowData;
this.exportData.push(rowData);
}
console.log(this.exportData);
this.excelExportService.exportData(this.exportData,new IgxExcelExporterOptions("ExportedDataFile"));
this.exportData = [];
}
This Export excel topic 将进一步帮助您。
使用此作为起点和 igxGrid row selection.