TanStack Table version
table-core v8.17.3
Framework/Library version
react
Describe the bug and the steps to reproduce it
current implementation for cell.getIsAggregated is
|
!cell.getIsGrouped() && !cell.getIsPlaceholder() && !!row.subRows?.length |
i would argue that row.subRows?.length is not supposed to be there.
look:

as we can see, aggregated cells exists even if no subrows exists for this group. this happens on custom getGroupedRowModel that i implement that makes sure that certain grouping values always exists even if there is no current rows for them(full explanation).
this is not a bug, but rather would say unexpected behavior for the method cell.getIsAggregated. i would argue that at least the next major release should change this behavior.
in my case, checking for row.depth === 0 instead is enough:
const customIsAggregated = !cell.getIsGrouped() && !cell.getIsPlaceholder() && row.depth === 0;
let renderedCellValue =
customIsAggregated && columnDef.AggregatedCell
...

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
.
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct
TanStack Table version
table-core v8.17.3
Framework/Library version
react
Describe the bug and the steps to reproduce it
current implementation for
cell.getIsAggregatedistable/packages/table-core/src/features/ColumnGrouping.ts
Line 396 in 22e1ac4
i would argue that
row.subRows?.lengthis not supposed to be there.look:
as we can see, aggregated cells exists even if no subrows exists for this group. this happens on custom getGroupedRowModel that i implement that makes sure that certain grouping values always exists even if there is no current rows for them(full explanation).
this is not a bug, but rather would say unexpected behavior for the method
cell.getIsAggregated. i would argue that at least the next major release should change this behavior.in my case, checking for
row.depth === 0instead is enough:Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
.
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct