【问题标题】:How to export data displayed in current page only in Ag-Grid?如何仅在 Ag-Grid 中导出当前页面中显示的数据?
【发布时间】:2020-09-23 04:26:07
【问题描述】:

默认情况下(不传递参数),当您从 ag-grid 导出数据时,它会导出所有页面中的所有数据。如何将其设置为仅导出当前页面中显示的数据?

【问题讨论】:

    标签: reactjs ag-grid ag-grid-react


    【解决方案1】:

    您可以使用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
    将在网格中的每行调用一次的回调函数。返回 true 以从导出中省略该行。

    Example 来自 ag-grid 文档

    【讨论】:

    • 非常感谢 Pratik Bhat!
    • 很高兴它有帮助。如果对您有帮助,您可以通过单击对勾图标来接受答案
    猜你喜欢
    • 2020-02-24
    • 2021-09-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 2019-06-06
    • 2012-03-18
    • 1970-01-01
    • 2017-01-31
    相关资源
    最近更新 更多