Pagination
Introduction
By default, all Tables are paginated and the user can select how many rows to display per page. The pagination controls are displayed at the bottom of the table. The default options are 15
, 30
, 50
, and 100
rows per page, and 15
rows per page is selected by default.
Per Page Options
You can customize the pagination options by setting the $perPageOptions
property in your Table class:
class Users extends Table
{
protected ?array $perPageOptions = [50, 100, 250];
}
If you want this to be the default for all tables, you may call the static defaultPerPageOptions()
method on the Table class, for example, in your AppServiceProvider
:
use InertiaUI\Table\Table;
Table::defaultPerPageOptions([50, 100, 250]);
Disable Pagination
Though absolutely not recommended, you can disable pagination by setting the $pagination
property to false
:
class Users extends Table
{
protected bool $pagination = false;
}
Scroll Position
When the user changes the page, the browser will scroll to the top of the page, just like a regular page load. If you want to maintain the scroll position or scroll to the top of the table, you can use the $scrollPositionAfterPageChange
property with the ScrollPosition
enum.
The available options are:
ScrollPosition::Preserve
ScrollPosition::TopOfPage
(default)ScrollPosition::TopOfTable
use InertiaUI\Table\ScrollPosition;
class Users extends Table
{
protected ?ScrollPosition $scrollPositionAfterPageChange = ScrollPosition::TopOfTable;
}
If you want this to be the default for all tables, you may call the static defaultScrollPositionAfterPageChange()
method on the Table class, for example, in your AppServiceProvider
:
use InertiaUI\Table\ScrollPosition;
use InertiaUI\Table\Table;
Table::defaultScrollPositionAfterPageChange(ScrollPosition::TopOfTable);