在服务器分页/排序/过滤模式下将数据导出到CSV [英] Export data to CSV in server pagination / sorting / filtering mode

查看:27
本文介绍了在服务器分页/排序/过滤模式下将数据导出到CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导出 数据到CSV.

I am trying to export the ag-grid data to CSV.

问题是,在考虑paginationPageSizemaxBlocksInCache时,它仅导出可见数据OR从HTTP调用接收到的内存数据,cacheBlockSize 等.不是整个数据集.

The issue is, it exports only the visible data OR the in-memory data received from HTTP call while considering paginationPageSize, maxBlocksInCache, cacheBlockSize etc. in the grid. Not the entire data-set.

我浏览了以下链接,但没有得到太多帮助.

I went through below links, but couldn't get much help.

  1. [export] 将客户端的所有页面导出为 CSV分页
  2. agGrid数据导出

有什么办法可以做到这一点吗?或者这完全不可能?

Is there any way we can achieve this? Or this is altogether not possible?

推荐答案

我就是这样解决的 -

This is how i solved this -

  1. 从数据源中获取您需要的所有行
  2. 克隆 gridapi 对象
  3. 从克隆的 gridapi 中获取服务器端缓存
  4. 对其进行处理,使其充满您获取的数据
  5. 在克隆的 gridapi 上运行导出到 excel 方法
  6. ...
  7. 利润

const gapi = cloneDeep(this.gridApi);//克隆 gridApi

const gapi = cloneDeep(this.gridApi); // clone gridApi

const blocks = gapi['serverSideRowModel'].rootNode.childrenCache.blocks;//抑制私有警告/错误的对象符号

const blocks = gapi['serverSideRowModel'].rootNode.childrenCache.blocks; // object notation to suppress private warning/err

  // swap rows cache with fetched data
  for (let i = 0, j = 0; i < Math.ceil(results.length/this.paginationPageSize); i++) {
    // we alter relevant block, or if it is not loaded yet we clone 1st one and alter it
    const block = blocks[i] || cloneDeep(blocks[0]);  
    block.rowNodes.forEach(n => n.data = results[j++]);
    blocks[i] = block;
  }
  gapi['serverSideRowModel'].rootNode.childrenCache.blocks = blocks;

  gapi.exportDataAsExcel(params);

这篇关于在服务器分页/排序/过滤模式下将数据导出到CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆