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

Pagination handling example #241

Closed
Polve opened this issue Jan 2, 2024 · 8 comments
Closed

Pagination handling example #241

Polve opened this issue Jan 2, 2024 · 8 comments

Comments

@Polve
Copy link

Polve commented Jan 2, 2024

In the class list I found something related to pagination but I can't find any example using it so I'm unable to understand how to use it

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Jan 2, 2024

Pagination is handled externally:
You'd do something like this (where you make the components, and YourTable wraps the headless table)

<Data as |d|>
  <YourTable @data={{d.records}} />
  <Pagination @meta={{d.meta}} @onNext={{d.nextPage}} />
</Data>

records would be tracked, no when the pagination component tells the data component to update, the table component updates because of auto tracking

The pagination interface in this repo was accidentally left in, and isn't actually used, afaik

@Polve
Copy link
Author

Polve commented Jan 2, 2024

Thanks

in the example above, how can I tell the table that I changed the @DaTa (without triggering a new route)?

@NullVoxPopuli
Copy link
Contributor

Why don't you want to trigger a route transition? Generally folks want table state serialized to the URL

@Polve
Copy link
Author

Polve commented Jan 2, 2024

Because I have several tables inside my page and I want to be able to paginate each one indipendently

@NullVoxPopuli
Copy link
Contributor

If you move all data loading for each table into component-land instead of the route, your goal is very doable

@Polve
Copy link
Author

Polve commented Jan 2, 2024

yes that's my goal, but how do I trigger a table redraw after pressing the pagination buttons?

@NullVoxPopuli
Copy link
Contributor

In the example, if records is @tracked , and your function for handling page changes updates records, there is nothing for you to do. The framework handles the update 🎉

I can share a real/runnable example later if you're still stuck

@Polve
Copy link
Author

Polve commented Jan 3, 2024

Everything works as expected, thanks!
I close this since I overlooked #163 that was already on topic

@Polve Polve closed this as completed Jan 3, 2024
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

2 participants