mantine-data-grid icon indicating copy to clipboard operation
mantine-data-grid copied to clipboard

Table State / Options - autoResetPagination missing?

Open Shadowfita opened this issue 3 years ago • 1 comments

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.

Shadowfita avatar Sep 13 '22 23:09 Shadowfita

I've also found reference to autoResetPageIndex in the react-table adapter.

Shadowfita avatar Sep 15 '22 01:09 Shadowfita

I am also facing the same issue.

PointSingularity avatar Sep 19 '22 18:09 PointSingularity

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!

Shadowfita avatar Sep 19 '22 23:09 Shadowfita

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 avatar Sep 20 '22 07:09 PointSingularity

@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 avatar Sep 20 '22 07:09 Shadowfita

@Shadowfita Thank you 😁 If you need help, I can maybe take a glance at it!

PointSingularity avatar Sep 20 '22 08:09 PointSingularity

@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 avatar Sep 20 '22 22:09 Shadowfita

@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?

PointSingularity avatar Sep 21 '22 06:09 PointSingularity

@Shadowfita Could you provide a Example to reproduce this behavior?

Kuechlin avatar Sep 21 '22 08:09 Kuechlin

@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!

Shadowfita avatar Sep 21 '22 08:09 Shadowfita

Update - I've tested again and it seems to be working as expected with no code changes. Not sure what's changed. Weird!

Shadowfita avatar Oct 05 '22 02:10 Shadowfita