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

时间:2016-07-20 01:20:15

标签: angular ag-grid

在数据中,我试图使用组单元格渲染器来显示行内的子表数据。它完美地运作。当我尝试在同一行中的另一列上使用组单元格渲染器时,它不起作用,因为组键符合编译器最后读取的任何引用。基于此,有没有办法可以覆盖组单元格渲染器参数以允许单行中多个参数?

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'}
    ]
  }

];

enter image description here

1 个答案:

答案 0 :(得分:0)

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