Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

how to allow only table to expand one row at a time #5544

Closed
2 tasks done
linaffilomania opened this issue May 12, 2024 · 2 comments
Closed
2 tasks done

how to allow only table to expand one row at a time #5544

linaffilomania opened this issue May 12, 2024 · 2 comments

Comments

@linaffilomania
Copy link

TanStack Table version

e.g. @tanstack/react-table": "^8.11.0

Framework/Library version

e.g. React 18.2.0

Describe the bug and the steps to reproduce it

how i can that just one expand will be open

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

.

Screenshots or Videos (Optional)

.

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.
@Darkmift
Copy link

this allows limiting main rows to only 1 open but allows normal expand logic in sub rows

        onClick: () => {
                      const state = table.getState();
                      const expanded = structuredClone(state.expanded) as Record<
                        string,
                        boolean
                      >;
                      if (row.id.includes('.')) {
                        expanded[row.id] = !row.getIsExpanded();
                        table.setExpanded(expanded);
                        return;
                      }

                      table.setExpanded(row.getIsExpanded()?{}:{ [row.id]: true });
                      // return row.getToggleExpandedHandler();
                    },

@KevinVandy
Copy link
Member

This is what I do:

onClick: () => table.setExpanded({ [row.id]: !row.getIsExpanded() }), //only 1 detail panel open at a time

^Above advice is about the same and good too.

Let's leave issues for bugs and convert this into a discussion

@TanStack TanStack locked and limited conversation to collaborators Jun 3, 2024
@KevinVandy KevinVandy converted this issue into discussion #5589 Jun 3, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants