mantine-data-grid
mantine-data-grid copied to clipboard
Table State / Options - autoResetPagination missing?
Hi,
Does this wrapper of React Table expose autoResetPagination anywhere? I'm trying to prevent the page index from changing on data refresh.
https://tanstack.com/table/v8/docs/api/features/pagination#autoresetpagination
Love this project!
Thanks.
I've also found reference to autoResetPageIndex in the react-table adapter.
I am also facing the same issue.
I am also facing the same issue.
I tried implementing the props I found which was in my original pull request but found they didn't make a difference. It seems that something is calling pageIndexReset or setting it to 0, because the onPageChange event is firing with index 0 when the data refreshes.
If you come up with a decent solution, please let me know!
pageIndexReset
Hey, I tried the changes you made, and they did actually work for me!
My use case is the following:
I have a monorepo React/Express (TypeScript). I get the data from the backend with React Query and feed it into the table, with a special column with a button for deleting data. When a row is deleted, the query is invalidated. Before your changes the page was reset, after using the "autoResetPageIndex" it stays on the same page.
So I would say you should reopen your pull request!
@PointSingularity that's really good to hear! I'm not quite sure why it didn't work for me then. I will have to investigate further.
@Shadowfita Thank you 😁 If you need help, I can maybe take a glance at it!
@PointSingularity Yeah it's odd. I've set the autoResetPageIndex to false, however, when the data changes it jumps back to the first page. I'm passing the data into the data prop of the table which is populated by an SWR request. Once I submit the change to the backend, I mutate once successful and then it resets the page index. Not sure whats going on.
@Shadowfita That sounds similar to what I am doing, just with the difference of SWR instead of React Query (and they should be very similar). Maybe there is a component higher up, that also uses the same data, and it re-renders the whole thing?
@Shadowfita Could you provide a Example to reproduce this behavior?
@Shadowfita Could you provide a Example to reproduce this behavior?
No worries @Kuechlin , I'll get an example for you. Thanks heaps for approving my (simple) pull!
Update - I've tested again and it seems to be working as expected with no code changes. Not sure what's changed. Weird!