Ag-Grid中如何只导出当前页面显示的数据?
How to export data displayed in current page only in Ag-Grid?
默认情况下(不传递参数),当您从 ag-grid 导出数据时,它会导出所有页面中的所有数据。如何设置只导出当前页面显示的数据?
您可以使用 shouldRowBeSkipped
参数选项并定义导出函数,如 -
export = () => {
var firstRow = this.gridApi.getFirstDisplayedRow();
var lastRow = this.gridApi.getLastDisplayedRow();
var shouldRowBeSkipped = (params) => {
// return true if index is less than first row or more than last row
return params.node.rowIndex < firstRow || params.node.rowIndex > lastRow;
}
var params = {
shouldRowBeSkipped : shouldRowBeSkipped
}
}
根据文档 -
shouldRowBeSkipped
A callback function that will be invoked once per row in the grid. Return true to omit the row from the export.
Example 来自 ag-grid 文档
默认情况下(不传递参数),当您从 ag-grid 导出数据时,它会导出所有页面中的所有数据。如何设置只导出当前页面显示的数据?
您可以使用 shouldRowBeSkipped
参数选项并定义导出函数,如 -
export = () => {
var firstRow = this.gridApi.getFirstDisplayedRow();
var lastRow = this.gridApi.getLastDisplayedRow();
var shouldRowBeSkipped = (params) => {
// return true if index is less than first row or more than last row
return params.node.rowIndex < firstRow || params.node.rowIndex > lastRow;
}
var params = {
shouldRowBeSkipped : shouldRowBeSkipped
}
}
根据文档 -
shouldRowBeSkipped
A callback function that will be invoked once per row in the grid. Return true to omit the row from the export.
Example 来自 ag-grid 文档