Skip to content

ColumnGrouping.getDefaultColumnDef should not return aggregatedCell #5778

Open
@tychenjiajun

Description

@tychenjiajun

TanStack Table version

v8.20.5

Framework/Library version

v18.3.1

Describe the bug and the steps to reproduce it

flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext()) becomes meaningless because then aggregatedCell is not defined, the default aggregatedCell return from ColumnGrouping.getDefaultColumnDef is used.

  1. Open the following CodeSandbox
  2. Click status to group status column
  3. Profile Progress show 49.995466826778745, expected to be Profile Progress show 50%

Temporal solution: use null or undefined:

{
                accessorKey: 'progress',
                header: 'Profile Progress',
                cell: ({ getValue }) =>
                  Math.round(getValue<number>() * 100) / 100 + '%',
                aggregationFn: 'mean',
                aggregatedCell: null,
                // aggregatedCell: ({ getValue }) =>
                //   Math.round(getValue<number>() * 100) / 100 + '%',
}

or

    defaultColumn:{
       aggregatedCell: undefined,
     }

but it looks weird and unnecessary.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/github/tanstack/table/tree/main/examples/react/grouping?embed=1&theme=dark

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions