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 can I get au-table to render the current page without it being reset to 1? #23

Open
matdar opened this issue Feb 6, 2017 · 3 comments
Assignees

Comments

@matdar
Copy link

matdar commented Feb 6, 2017

Hello

I have an au-table that displays rows, the user can page through the data and click a button which navigates to a view to display the selected row's details. When the user goes back to the master list view I need to be able to open the table on the page the user was on when they viewed the details.

I've bound currentPage which is held in a singleton to preserve the value, however when the user navigates back to the master list the data is reloaded and the currentPage is reset to 1 (by au-table).

Is there a way I can get the table to render the current page without it being reset to 1?

Thanks
Matt

@tochoromero tochoromero self-assigned this Feb 7, 2017
@tochoromero
Copy link
Owner

Hello, I can see your problem. I think the easiest way to do it is to have a way to force a specific page on the table.
The page is being reset because filter changes, data size changes, sort changes affect pagination, so the easiest approach is just to reset the current page to 1 whenever any of those happen.

Something you can do right now is to give Aurelia Table a chance to initialize itself, then set the current page to whatever you need it to be. If you set the current page after the data is set you should be good, but just to be sure you can delay the setting of the current page a little bit.

If this approach is not working, we can expose a method on aurelia table to set the current page.

@matdar
Copy link
Author

matdar commented Feb 7, 2017

Thanks for response - I did try and place the currentPage update in the various aurelia view lifecycle events but that didn't set the page correctly. Putting a promise based sleep for a tenth of a second after the data fetch resolved did work but it's not ideal. A method to set the currentPage would be perfect.

@jdparke12
Copy link

Hey,

Was there any work on creating a method to set the currentPage. I've got it working using a window.setTimeout with 100ms delay but it causes a slight flicker in the table. If we could set currentPage to something like [myCurrentPage] instead of back to '1' and we could also bind to myCurrentPage that should solve the flicker right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants