Reputation: 337
In AgGrid multi-group column scenario, how to display first column to have count number of second column.?
In a below example, United states shows (1109) rows in it, but i want to show (7), count of years in it.
So it should show United States (7)
.How to achieve this ?
Upvotes: 1
Views: 1045
Reputation: 628
Seems like defining a custom innerRenderer
inside the group settings might be right solution here.
autoGroupColumnDef
attribute inside gridOptions
as configuration used by the auto group columnsvar gridOptions = {
autoGroupColumnDef: {
width: 200,
headerName: 'Group', //header name of the group
cellRenderer: 'agGroupCellRenderer', //default cell renderer for groupings
// provide extra params to the cellRenderer
cellRendererParams: {
suppressCount: true, // turn off the row count (in order to skip default stack counting)
innerRenderer: customInnerRenderer, //our inner renderer in charge of child nodes counting
}
},
//other settings
columnDefs: columnDefs,
animateRows: true,
enableRangeSelection: true,
rowData: null
};
customInnerRenderer
that will handle the counting displayfunction customInnerRenderer(params){
//this verification is necessary, otherwise the grid will brake down
//when last level without grouping will be reached (if exists)
if (params.node.group) {
var label = params.value ? params.value : '-';
return label + ' (' + params.node.childrenAfterFilter.length + ')';
}
}
Upvotes: 4