Joel
Joel

Reputation: 97

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

Within the data, I am trying to use the group cell renderer to display sub-table data within a row. it works perfectly. When I try to use the group cell renderer on another column in the same row, it doesn't work because the group key honors whichever reference is read last by the compiler. Based on that, is there any way that I can override the group cell renderers parameters to allow for more than one in a single row?

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

Upvotes: 2

Views: 4679

Answers (1)

Joel
Joel

Reputation: 97

Solved: Rather than hack to a second group key, I just appended the second table's data to the first table's data via the row_data array. Basically, just combine the objects. The column definitions allowed me to still partition the data with its own headers. Only needed to use a single group key.

Upvotes: 1

Related Questions