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

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

Open
2 tasks done
linaffilomania opened this issue May 12, 2024 · 1 comment
Open
2 tasks done

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

linaffilomania opened this issue May 12, 2024 · 1 comment

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();
                    },

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

2 participants