ag-grid:在一行中使用多个组单元格渲染

ag-grid: use more than one group cell rendering in a single row

在数据中,我试图使用组单元格渲染器在一行中显示子table 数据。它工作得很好。当我尝试在同一行的另一列上使用组单元格渲染器时,它不起作用,因为组键遵循编译器最后读取的引用。基于此,有什么方法可以覆盖组单元格渲染器参数以允许在一行中使用多个?

let columnDefs = [
  {headerName: 'Company', field: 'company'},
  {headerName: 'Job', field: 'job'},
  {headerName: 'Time Wasted', field: 'timeWasted'},
  {headerName: "People",
    children: [
  {headerName: "", cellRenderer: 'group'},
  {headerName: "Athlete", field: "athlete"},
  {headerName: "Year", field: "year"},
  {headerName: "Country", field: "country"},
    ]
  },
  {
    headerName: "Details",
    children: [
      {headerName: "", cellRenderer: 'group'},
      {headerName: "Time", field: "time"},
      {headerName: "Speed", field: "speed"},
      {headerName: "Distance", field: "distance"}
    ]
  }
];

//options for chart configuration
this.options = {
  columnDefs: columnDefs,
  enableColResize: true,
  enableSorting: true,
  getNodeChildDetails: getNodeChildDetails,
  enableFilter: true,
  rowSelection: 'multiple'
};

this.data = [
  { company: 'BMI',
    job: 'developer',
    timeWasted: '15 days',
    group: 'People',
    participants: [
      {athlete: 'Jimmy Blue', year: '2008', country: 'United States'},
      {athlete: 'Jack Brown', year: '2009', country: 'China'},
      {athlete: 'Jeff White', year: '2010', country: 'India'}
    ],
    group: 'Details',
    stuff: [
      {time: '14:04', speed: '11', distance: '1.2'},
      {time: '16:03 ', speed: '12', distance: '1.25'},
      {time: '17:00', speed: '12', distance: '.99'}
    ]
  }

];

已解决:我没有破解第二个组密钥,而是通过 row_data 数组将第二个 table 的数据附加到第一个 table 的数据。基本上,只需组合 objects。列定义允许我仍然使用自己的 headers 对数据进行分区。只需要使用一个组密钥。