I want to use row group renderer. Notice [ groupRowRendererFramework: groupRowInnerRenderer ] in the below code. I have added group renderer. When i run the code then in all the rows i see ‘Hello World’. I just want to see ‘Hello World’ in one row and then i want to display other column values. ‘Hello World’ is coming from my custom group renderer. Can you please help, what piece of the code i am missing in my custom group row renderer?
Code
import GroupRowInnerRenderer from './GroupRowInnerRenderer';
const App = () => {
const [rowData, setRowData] = useState();
useEffect(() => {
fetch('https://www.ag-grid.com/example-assets/olympic-winners.json')
.then(result => result.json())
.then(rowData => setRowData(rowData))
}, []);
const defaultColDef = useMemo( ()=> ( {
resizable: true,
}), []);
const [columnDefs, setColumnDefs] = useState([
{ field: 'athlete'},
{ field: 'age', headerName: 'Age12' },
{ field: 'country' , rowGroup: true },
{ field: 'year' },
{ field: 'date' },
{ field: 'sport' },
{ field: 'gold' },
{ field: 'silver' },
{ field: 'bronze' },
{ field: 'total' }
]);
const gridOptions:GridOptions = {
suppressMovableColumns: true,
suppressContextMenu: true,
enableRangeSelection: true,
suppressRowTransform: true,
columnDefs: [...columnDefs],
defaultColDef,
singleClickEdit: true,
groupUseEntireRow: true,
animateRows: true,
groupRowRendererFramework: GroupRowInnerRenderer
}
return (
<>
<div className="ag-theme-alpine" style={{height: 700, width: '100%'}}>
<AgGridReact
animateRows={true}
rowData={rowData}
gridOptions={gridOptions}
autoGroupColumnDef={{ minWidth: 200 }}
>
</AgGridReact>
</div>
</>
);
};
export default App;
Source For : GroupRowInnerRenderer.jsx
import React, { useEffect, useState } from 'react';
export default (props) => {
console.log('props=',props)
return (
<div>
<span>Hello World</span>
</div>
);
}
2
Answers
You are beginning the name of a react component with a lowercase letter. Try using GroupRowInnerRenderer as the reference name when you are importing.
Working Plunker: https://plnkr.co/plunk/8FhpsTWT6FVjyf1g
Details
Changed your groupRowInnerRenderer.jsx file like that
and imported it in your main app like that
There is no option like ‘groupRowRendererFramework’, used groupRowRendererParams instead
Removed total from your columnDefs
Added columnTypes
Fetched your data in onGridReady