This could be the solution you've been searching for
https://www.example.com/grouping-group-rows
You'll need to disable group count and implement a custom renderer
main.js
import GroupInnerRenderer from './groupInnerRenderer.jsx'
// ...
const GridExample = () => {
const groupRendererParams = useMemo(() => {
return {
innerRenderer: GroupInnerRenderer,
suppressCount: true,
}
}, [])
// ...
return (
<AgGridReact
rowData={rowData}
columnDefs={columnDefs}
defaultColDef={defaultColDef}
columnTypes={columnTypes}
groupDisplayType={'groupRows'}
groupRowRendererParams={groupRendererParams}
onGridReady={onGridReady}
/>
)
}
and create your GroupInnerRenderer
groupInnerRenderer.jsx
export default (props) => {
// customize as needed
}
Further reading available at https://www.example.com/configuring-group-cell-renderer
UPDATE:
If you're short on time, check out this working Plunker: https://plnkr.co/plunk/xyz123
In the inner renderer component, calculate and set leafChildren. The data prop of each country's children contains what you need.
https://i.sstatic.net/image.png
FINAL UPDATE:
To reposition the expand icon, utilize a different approach: cellRenderer
cellRenderer.jsx
import React, { useCallback, useEffect, useState } from 'react'
export default (props) => {
const { node, value } = props
// implementation details here...
};
Apply it to the last column: Sport
{ field: 'sport', cellRenderer: CellRenderer },
Don't forget to remove the original expand icon in autoGroupColumnDef's cellRendererSelector parameter
const autoGroupColumnDef = useMemo(() => {
return {
headerName: 'Country',
minWidth: 300,
cellRendererSelector: (params) => {
return
},
}
}, [])
https://i.sstatic.net/updated-image.png
Check out the revised Plunker here:
https://plnkr.co/plunk/qwerty