Beartropy Tables
Pagination Settings
Control page size and available options via the settings() method.
Configure Pagination
usePagination(bool $bool) — Enable or disable pagination entirely. Enabled by default.
setPerPageDefault(int $number) — Set the initial number of rows per page.
setPerPageOptions(array $options) — Define the available page size options in the dropdown.
1$this->usePagination(true);2$this->setPerPageDefault(50);3$this->setPerPageOptions(['10', '25', '50', '100', 'Total']);
The "Total" option
'Total' in setPerPageOptions() to let users display all rows on a single page. This is useful for smaller datasets where users want to see everything at once.
Disabling Pagination
Show all rows without pagination controls.
Disable Pagination
Set usePagination(false) to display all data rows without any pagination controls or page size selector.
1$this->usePagination(false);
Performance consideration
Examples
Playground tables demonstrating pagination configurations.
PaginatedUsersTable.php
Custom page size defaults and extended options including a "Total" option to show all rows.
1use App\Models\User; 2use Beartropy\Tables\Classes\Columns\Column; 3use Beartropy\Tables\Classes\Columns\DateColumn; 4use Beartropy\Tables\YATBaseTable; 5 6class PaginatedUsersTable extends YATBaseTable 7{ 8 public $model = User::class; 9 10 public function columns(): array11 {12 return [13 Column::make('Name', 'name')->sortable()->searchable(),14 Column::make('Email', 'email')->sortable(),15 DateColumn::make('Created', 'created_at')16 ->outputFormat('M d, Y'),17 ];18 }19 20 public function settings(): void21 {22 $this->setPerPageDefault(5);23 $this->setPerPageOptions(['5', '10', '25', '50', '100', 'Total']);24 }25}
NoPaginationTable.php
An array-based table with pagination disabled — all rows are displayed at once.
1use Beartropy\Tables\Classes\Columns\Column; 2use Beartropy\Tables\YATBaseTable; 3 4class NoPaginationTable extends YATBaseTable 5{ 6 public function columns(): array 7 { 8 return [ 9 Column::make('#', 'id')->sortable(),10 Column::make('City', 'city')->sortable()->searchable(),11 Column::make('Country', 'country')->sortable()->searchable(),12 Column::make('Population', 'population')->sortable()->pushRight(),13 ];14 }15 16 public function data(): array17 {18 return [19 ['id' => 1, 'city' => 'Tokyo', 'country' => 'Japan', 'population' => '13,960,000'],20 ['id' => 2, 'city' => 'Delhi', 'country' => 'India', 'population' => '11,030,000'],21 // ... more rows22 ];23 }24 25 public function settings(): void26 {27 $this->usePagination(false);28 }29}
Live Demo
Try it — change pages and adjust the per-page selector.
Paginated Table
-
5
-
10
-
Total
| # |
#
|
City
|
Country
|
Population
|
|---|---|---|---|---|
| 1 | 1 | Tokyo | Japan | 13,960,000 |
| 2 | 2 | Delhi | India | 11,030,000 |
| 3 | 3 | Shanghai | China | 24,870,000 |
| 4 | 4 | Sao Paulo | Brazil | 12,330,000 |
| 5 | 5 | Mexico City | Mexico | 9,210,000 |
1<livewire:tables.demos.demo-paginated-table />