Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

Griddle pagination does not keep track of current page

Open moraleslos opened this issue 7 years ago • 5 comments

I'm using the local plugin with pagination but griddle does not keep track of the page # if a user presses the back button. For example, say I have 10 pages in my pagination and the user is currently on page 5. That user then clicks on a link which directs to another page. When the user finishes with that page, he/she clicks the back button to go back to the griddle grid. However griddle starts from page 1 again-- I want the user to go back to page 5. I'm not sure if this is a bug with griddle or more of a feature request. I'm using Griddle 1.6.0.

moraleslos avatar Jul 21 '17 16:07 moraleslos

@moraleslos the Griddle state is saved in a local store. You would need to persist this somewhere else in the app if you want the current page to be saved.

Sounds like a good feature though!

sww314 avatar Jul 21 '17 17:07 sww314

I think when we are approaching a version 2, we want to make it way more accessible than saying "take a peek in Griddle's redux store to change things". I think the store is a good way for Griddle to manage stuff internally and for plugins but it would be nice as a consumer to not have to think about such things :D

ryanlanciaux avatar Jul 21 '17 17:07 ryanlanciaux

@sww314 I could try what you said later on (at the moment I don't know how to retrieve Griddle's local store) but I'd figure this should already be implemented since if Griddle already has the current state for the page, why not use it by default?

@ryanlanciaux Yes, that would be great if this could be implemented down the road, maybe by the next release? ;-) I'd figured this should already be the default behavior due to typical expectations of browser navigation.

moraleslos avatar Jul 21 '17 18:07 moraleslos

Why not use it by default?

We have the information but would prefer not to dictate that sort of behavior for everyone. This would be an awesome feature but would prefer if the consuming application pushed the current page in or this lived as a griddle plugin that kept track of history.

One of the main principles behind Griddle 1.x is to push functionality to plugins to avoid sending the kitchen sink down when someone includes Griddle from npm. That all said, I think providing an easier ability to interact with this from the consuming application is definitely something we'll try to tackle in the next version. For now, a plugin or something along those lines would be great.

ryanlanciaux avatar Jul 21 '17 18:07 ryanlanciaux

It seems like it would be really difficult to solve this in a generic way, since there are lots of ways that one could store the current grid state (Local Storage, history, etc). I would be curious if any other React grid components try.

It would definitely be possible to write a plugin that adds support for react-router or react-router-redux.

dahlbyk avatar Jul 22 '17 16:07 dahlbyk