Compare commits

...

1 Commits

Author SHA1 Message Date
Mehmet Salih Yavuz
361b26f224 feat(ag-grid-table): add control to hide row group counts
Adds a "Show row group counts" toggle (default on) above the existing
"Show summary" control. When disabled, suppresses the per-group row
count shown next to row group labels in the AG Grid table chart.
2026-05-08 17:22:45 +03:00
6 changed files with 49 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ export interface AgGridTableProps {
renderTimeComparisonDropdown: () => JSX.Element | null;
cleanedTotals: DataRecord;
showTotals: boolean;
showRowGroupCounts: boolean;
width: number;
onColumnStateChange?: (state: AgGridChartStateWithMetadata) => void;
onFilterChanged?: (filterModel: Record<string, any>) => void;
@@ -142,6 +143,7 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
renderTimeComparisonDropdown,
cleanedTotals,
showTotals,
showRowGroupCounts,
width,
onColumnStateChange,
onFilterChanged,
@@ -186,6 +188,15 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
[],
);
const autoGroupColumnDef = useMemo<ColDef>(
() => ({
cellRendererParams: {
suppressCount: !showRowGroupCounts,
},
}),
[showRowGroupCounts],
);
// Memoize container style
const containerStyles = useMemo(
() => ({
@@ -510,6 +521,7 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
rowHeight={30}
columnDefs={colDefsFromProps}
defaultColDef={defaultColDef}
autoGroupColumnDef={autoGroupColumnDef}
onColumnGroupOpened={params => params.api.sizeColumnsToFit()}
rowSelection="multiple"
animateRows

View File

@@ -80,6 +80,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
colorPositiveNegative,
totals,
showTotals,
showRowGroupCounts,
columnColorFormatters,
basicColorFormatters,
width,
@@ -444,6 +445,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
}
cleanedTotals={totals || {}}
showTotals={showTotals}
showRowGroupCounts={showRowGroupCounts}
width={width}
onColumnStateChange={handleColumnStateChange}
chartState={chartState}

View File

@@ -429,6 +429,22 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'show_row_group_counts',
config: {
type: 'CheckboxControl',
label: t('Show row group counts'),
renderTrigger: true,
default: true,
description: t(
'Show the number of rows in each group next to the group label when row grouping is enabled.',
),
visibility: isAggMode,
resetOnHide: false,
},
},
],
[
{
name: 'show_totals',

View File

@@ -504,6 +504,7 @@ const transformProps = (
show_cell_bars: showCellBars = true,
color_pn: colorPositiveNegative = true,
show_totals: showTotals,
show_row_group_counts: showRowGroupCounts = true,
conditional_formatting: conditionalFormatting,
comparison_color_enabled: comparisonColorEnabled = false,
comparison_color_scheme: comparisonColorScheme = ColorSchemeEnum.Green,
@@ -778,6 +779,7 @@ const transformProps = (
colorPositiveNegative,
totals,
showTotals,
showRowGroupCounts,
columnColorFormatters,
basicColorColumnFormatters,
basicColorFormatters,

View File

@@ -124,6 +124,7 @@ export interface AgGridTableChartTransformedProps<
colorPositiveNegative: boolean;
totals: DataRecord | undefined;
showTotals: boolean;
showRowGroupCounts: boolean;
columnColorFormatters: ColorFormatters;
basicColorFormatters?: { [Key: string]: BasicColorFormatterType }[];
basicColorColumnFormatters?: { [Key: string]: BasicColorFormatterType }[];

View File

@@ -35,6 +35,22 @@ beforeEach(() => {
jest.clearAllMocks();
});
test('transformProps defaults showRowGroupCounts to true', () => {
expect(transformProps(testData.basic).showRowGroupCounts).toBe(true);
});
test('transformProps respects show_row_group_counts=false', () => {
expect(
transformProps({
...testData.basic,
rawFormData: {
...testData.basic.rawFormData,
show_row_group_counts: false,
},
}).showRowGroupCounts,
).toBe(false);
});
test('transformProps parses pageLength to pageSize', () => {
expect(transformProps(testData.basic).pageSize).toBe(20);
expect(