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

Reset sorting to default (or nothing) on external event #1260

Open
Sigfried opened this issue Nov 14, 2024 · 0 comments
Open

Reset sorting to default (or nothing) on external event #1260

Sigfried opened this issue Nov 14, 2024 · 0 comments

Comments

@Sigfried
Copy link

I've read #590 but don't really understand the outcome. However, at some point in that discussion, I think @jbetancur asked what the use case is. My use case is this: I have this kind of crazy but very useful nested data table:
image

Because of the nesting, sorting has to be done at each indent level, and I do that through my initial sorting of the data and I set sortable: false on all columns. However, sometimes the user does want to sort, so I allow them to turn nesting off and then the columns toggle to sortable: true. But when they turn nesting back on, the table stays sorted, which means the nesting makes no sense:
image

I would just like to tell the table to go back to it's initial state. I tried forcing a rerender by replacing data with a copy ([...data]), but that's not doing anything.

In writing this issue, I did figure out a klunky workaround: in my event handler for toggling nesting back on, window.location.reload().

So, maybe I misunderstood and there's already a way to do this without that workaround, or maybe this use case is argument enough for implementing a reset feature, but, with the workaround, it's not a dire situation for me.

Thanks for the component! It's helped me a lot over the years.

Sigfried added a commit to jhu-bids/TermHub that referenced this issue Nov 14, 2024
…f43-bb59-5c48d56fe497)

- Now have a toggle button for switching between nested and unnested. The only way I could figure out to get the original sort order back after going back to nested is by reloading the whole page. A bit clunky, but it works.
- I did open an issue jbetancur/react-data-table-component#1260 to see if react-data-table-component can provide a way to do this without a reload, but not super important.
- Fixes #929 and #506
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