skeleton icon indicating copy to clipboard operation
skeleton copied to clipboard

Add information on how to have server side pagination with a dynamic size

Open FranciscoAX opened this issue 3 years ago • 0 comments

Link to the Page

https://www.skeleton.dev/components/paginators

Describe the Issue (screenshots encouraged!)

I was having an issue while using the paginator, as it broke (numbers stopped updating correctly when changing page) when I added filters to my table (which in turn makes the size parameter dynamic, as it changes based on the select filters).

I found no information in the documentation for this rather common pattern and I was able to come up with a solution of my own, with some help from other developers in the Discord server. However, I believe that, given how common this pattern is, it would make sense to add an example in the documents.

Here is my final solution:

paginationSettings = {
        page: Number($page.url.searchParams.get('pageNumber')),
        limit: 5,
        size: Number(data.Count), // This is the total count of the filtered data at any time and it is dynamic.
        amounts: []
    } satisfies PaginationSettings;

$: paginationSettings.size = Number(data.Count); // This ensures that the size property is updated whenever the load function runs (hence, when the data is filtered).

FranciscoAX avatar Nov 03 '23 16:11 FranciscoAX