Issue Paginating Multiple Tables in Admin Dashboard
I'm utilizing two widgets in the Filament dashboard, which happen to be two tables. However, when I paginate one of them, the URL simply displays "/admin?page=n" without specifying the table's identity. Despite implementing
queryStringIdentifier
for both tables, I'm unable to discern which table's page is being displayed. Is there a crucial step I'm overlooking? 🤔
on table 1:
on table 2:
Solution:Jump to solution
try to use this method in the widget
```php
protected function paginateTableQuery(\Illuminate\Database\Eloquent\Builder $query): \Illuminate\Contracts\Pagination\Paginator
{...
14 Replies
anyone ^^
Solution
try to use this method in the widget
awesome
thanks a lot 🙏
Sorry, remove this code and use this trait
this will override the simple pagination
ohh cool
is this in the docs? i think we should add it
no
no, for the 1st question i guess u mean
this isn't in the docs I guess
@Leandro Ferreira Hi!! I'm also using two widget table on a single page, but I'm facing an issue, Let me describe the issue
Let's say I've 2 tables Payments and Anonymous payments now Payments has 20 records and Anonymous payment has 4 records and each table shows 10 data by default, now when I go the next page of pagination in Payments table, it shows the data of 10-20 but if I refresh the page the same 10-20 data of Payments shows but the Anonymous table shows null data because in the URL it shows page=2 (e.g.
http://127.0.0.1:8000/admin/event/payments?page=2
) and no pagination shows to get back to the 4 Anonymous payment data. So Could you please tell if I can move through pagination without changing the URL, that would resolve it I guess?
Could you please help, thank you for your valuable time 🙂Thank you for your response 🙂
Here, I presume "users" is the resource model, Both of my widgets are from same resource and my issue remains same even after using the queryStringIdentifier, Could you please confirm if it's the model or not?
No it is an identifier that you can use different values to each widget tables
Here as you can see I've used 2 different identifiers for each table but when I refresh the page same issue occurs, please refer to the video, thank you
Hi! It's working after overriding the paginateTableQuery() function.