-
-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
The issue arises when changing the "Per Page" dropdown value after navigating to a different page.
Specifically:
- I navigated to page 2 of my data table.
- I changed the "Per Page" dropdown value to something other than the default (10).
- The table displayed 0 results when it should have shown the correct set of paginated data.
How to reproduce the bug
- Navigate to page 2 of the data table.
- The URL becomes: http://127.0.0.1:8000/admin/dashboard?page=2
- Change the "Per Page" dropdown value from 10 to 25.
- The URL updates to: http://127.0.0.1:8000/admin/dashboard?page=2&tableperPage=25
- The table displays 0 results.
Package Version
3.4.20
PHP Version
8.3.x
Laravel Version
11.9
Alpine Version
No response
Theme
Bootstrap 4.x
Notes
- Manually removing page=2& from the URL allows the table to display the correct results.
- I have a total of 14 rows
My Component
namespace App\Livewire\Datatables\Admin;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Columns\ButtonGroupColumn;
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateRangeFilter;
class UsersTable extends DataTableComponent
{
protected $model = User::class;
public function configure(): void
{
$this->setPrimaryKey('id');
$this->setSingleSortingDisabled();
$this->setLoadingPlaceholderStatus(true);
}
public function columns(): array
{
return [
Column::make('id')->hideIf(true)->eagerLoadRelations(),
ImageColumn::make('Profile')->location(fn($row) => $row->profile_url)->attributes(
fn($row) => [
'class' => 'rounded-circle border border-primary',
'style' => 'object-fit: cover; width: 32px; height: 32px;',
'loading' => 'lazy',
]
),
Column::make('Role', 'role')->sortable()->searchable()->excludeFromColumnSelect(),
Column::make('Username', 'username')->sortable()->searchable()->excludeFromColumnSelect(),
Column::make('Email', 'email')->sortable()->searchable(),
Column::make('Joined At', 'created_at')->sortable()->searchable(),
ButtonGroupColumn::make('Actions')->buttons([
LinkColumn::make('Visit') // make() has no effect in this case but needs to be set anyway
->title(fn() => '<i class="fa-solid fa-user-pen"></i>')
->location(fn($row) => route('profile', $row))
->attributes(function ($row) {
return [
'class' => 'btn btn-sm btn-primary mb-1',
'wire:navigate' => true,
];
})
->html(),
]),
];
}
public function filters(): array
{
return [
DateRangeFilter::make('Join date')
->config([
'allowInput' => true,
'altFormat' => 'F j, Y',
'placeholder' => 'Enter Date Range',
])
->filter(function (Builder $builder, array $dateRange) {
$builder->whereDate('users.created_at', '>=', $dateRange['minDate'])->whereDate('users.created_at', '<=', $dateRange['maxDate']);
}),
];
}
}
Error Message
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working