【问题标题】:How to copy rows from one ag-grid to second ag-grid如何将行从一个 ag-grid 复制到第二个 ag-grid
【发布时间】:2018-01-30 07:15:25
【问题描述】:

我的 UI 上有两个 ag-grids。 Ag-grid 1 有 4 行。 Ag-grid 2 有 5 行。两个 ag-grids 具有相同的列。 我想通过单击某个按钮将所有行从 Ag-grid 2 复制到 Ag-grid 1。 我该怎么做?

预期结果: 点击按钮。

  1. Ag-grid 1 应该有 9 行(4 个原始行和 5 个从 Ag-grid 2 复制的行)。
  2. Ag-grid 2 应该有 0 行

【问题讨论】:

    标签: angular ag-grid ag-grid-ng2


    【解决方案1】:

    使用这种功能:

    move(){
      var rows = this.agGrid2.api.getModel().rowsToDisplay.map(e=>e.data)
      this.agGrid1.api.updateRowData({add: rows})
      this.agGrid2.api.setRowData([])
    }
    

    这是plunker

    这完全按照您的要求回答,但是,听起来您或其他对从一个网格到另一个网格的移动类型函数感兴趣的人可能会发现使用 getSelectedRows() 而不是 getModel() 很有用

    【讨论】:

      猜你喜欢
      • 2021-09-21
      • 1970-01-01
      • 2020-03-07
      • 2019-05-23
      • 2022-06-18
      • 2022-10-25
      • 2020-08-19
      • 1970-01-01
      • 2017-05-20
      相关资源
      最近更新 更多