【问题标题】:Ag-grid render multiple rows in a cellAg-grid 在一个单元格中渲染多行
【发布时间】:2021-02-16 10:42:31
【问题描述】:

我是 Ag-grid(React 版本)的新手,在使用 Ag-Grid 渲染单元格中的多行时遇到了问题。

这是我们通过 React Table 所做的,但我们希望在 Ag-grid React 版本中做同样的事情。

有人知道我该怎么做吗?

非常感谢您的帮助。

【问题讨论】:

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


    【解决方案1】:

    查看此文档:Row Spanning Complex Example

    您可以使用ColDefrowSpan 属性,同时为您的ColDef 提供值。 为两列提供rowSpan1(在屏幕截图中可见第2和第3列),有条件地为第4列提供12,为其他列提供2

    colDef = [
      { field: 'field1', rowSpan: 2, /* other props */ },
      { field: 'field2', rowSpan: 1, /* other props */ },
      { field: 'field3', rowSpan: 1, /* other props */ },
      { field: 'field4', /* other props */, 
        rowSpan: (params) => {
          return  // your condition which decides rowSpan
        }
      },
      { field: 'field5', rowSpan: 2, /* other props */ },
      { field: 'field6', rowSpan: 2, /* other props */ }
    ];
    

    跨行也有一些限制。确保你也检查一下:Constraints with Row Spanning

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-13
      • 2017-06-11
      • 2018-02-13
      • 1970-01-01
      • 2021-05-12
      • 2018-09-22
      • 2017-10-25
      • 2018-09-30
      相关资源
      最近更新 更多