Pagination not showing in dashboard table widget

Hello All, On my dashboard I have given a table widget for expiry alert and it is not showing pagination as the default tables. It shows like this... Thank you.
No description
4 Replies
Dennis Koch
Dennis Koch8mo ago
I think by default table widgets use simple pagination. You should be able to configure that.
syed_eer
syed_eer8mo ago
thanks for your reply @Dennis Koch I think default pagination is this only. But I want it toshow the total results plus the page number. After exploring a bit I got this "use Tables\Concerns\InteractsWithTable;" but when I use this I cannot see the table heading as 'Expiry Alert'.
No description
Edoggg93
Edoggg938mo ago
Removing this from TableWidget solves the problem protected function paginateTableQuery(Builder $query): Paginator { return $query->simplePaginate($this->getTableRecordsPerPage() == 'all' ? $query->count() : $this->getTableRecordsPerPage()); }
LeandroFerreira
LeandroFerreira8mo ago
You can add this in the Widget class
protected function paginateTableQuery(\Illuminate\Database\Eloquent\Builder $query): \Illuminate\Contracts\Pagination\Paginator
{
$perPage = $this->getTableRecordsPerPage();

$records = $query->paginate(
$perPage === 'all' ? $query->count() : $perPage,
['*'],
$this->getTablePaginationPageName(),
);

return $records->onEachSide(0);
}
protected function paginateTableQuery(\Illuminate\Database\Eloquent\Builder $query): \Illuminate\Contracts\Pagination\Paginator
{
$perPage = $this->getTableRecordsPerPage();

$records = $query->paginate(
$perPage === 'all' ? $query->count() : $perPage,
['*'],
$this->getTablePaginationPageName(),
);

return $records->onEachSide(0);
}
UPDATE:
use \Filament\Tables\Concerns\CanPaginateRecords;
use \Filament\Tables\Concerns\CanPaginateRecords;