Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColumnGrouping.getDefaultColumnDef should not return aggregatedCell #5778

Open
2 tasks done
tychenjiajun opened this issue Oct 15, 2024 · 0 comments
Open
2 tasks done

Comments

@tychenjiajun
Copy link
Contributor

tychenjiajun commented Oct 15, 2024

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant