在AgGrid multi-group列方案中,如何显示第一列以具有第二列的计数。
在下面的示例中,美国在其中显示(1109)行,但我想在其中显示(7)年。
因此应该显示United States (7)
。如何实现?
答案 0 :(得分:0)
似乎在组设置中定义自定义innerRenderer
可能是正确的解决方案。
autoGroupColumnDef
内添加gridOptions
属性作为自动组列使用的配置var 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
以处理计数显示function 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 + ')';
}
}