Option to set default table pagination

Hi, I'm creating some tables that have plenty data in them. I have pagination enabled with the default options of [5, 10, 25, 50, 'all'] - I'd like to keep those options, but default the view to 25 rather than 10. Looking at CanPaginateRecords I can see the below method, but it seems that we either show 10 rows if it's in the options array, otherwise we just use the first item. I could override the default options and change 10 to 9 or 11, but that doesn't feel right.
public function getDefaultPaginationPageOption(): int | string | null
{
$option = $this->evaluate($this->defaultPaginationPageOption);

if ($option) {
return $option;
}

$options = $this->getPaginationPageOptions();

if (in_array(10, $options)) {
return 10;
}

return Arr::first($options);
}
public function getDefaultPaginationPageOption(): int | string | null
{
$option = $this->evaluate($this->defaultPaginationPageOption);

if ($option) {
return $option;
}

$options = $this->getPaginationPageOptions();

if (in_array(10, $options)) {
return 10;
}

return Arr::first($options);
}
Is there a way that I can get round this? Or request it as a feature in a future release? Cheers Adam
4 Replies
Tally
Tally9mo ago
use Filament\Tables\Table;

public function table(Table $table): Table
{
return $table
->defaultPaginationPageOption(25);
}
use Filament\Tables\Table;

public function table(Table $table): Table
{
return $table
->defaultPaginationPageOption(25);
}
Adam Holmes
Adam HolmesOP9mo ago
Perfect - not sure how I missed that! I've created a little helper that will be called on all tables and set some defaults 🙂 Thank you.
Tally
Tally9mo ago
Don't forget you can apply something to all your tables in your boot function of your provider

public function boot(): void
{
Table::configureUsing(function (Table $table) {
$table->paginated([50, 100, 'all'])
->defaultPaginationPageOption(100);
});
}

public function boot(): void
{
Table::configureUsing(function (Table $table) {
$table->paginated([50, 100, 'all'])
->defaultPaginationPageOption(100);
});
}

Did you find this page helpful?