Closed blite closed 2 years ago
Can I see some code please?
<?php
namespace App\Http\Livewire;
use App\Models\Post;
use App\Models\Category;
use Filament\Tables;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Component;
class ListPost extends Component implements Tables\Contracts\HasTable
{
use Tables\Concerns\InteractsWithTable;
protected function getTableQuery(): Builder
{
return Post::query();
}
protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('title')->sortable()->searchable()->url(
fn (Post $record): string => route('post.show', ['guide' => $record->slug])
),
Tables\Columns\TextColumn::make('subtitle')->sortable()->searchable()->url(
fn (Post $record): string => route('post.show', ['guide' => $record->slug])
),
Tables\Columns\TextColumn::make('category.title'),
];
}
protected function getTableFilters(): array
{
return [
Filter::make('is_active')->label('Active')
->query(fn (Builder $query): Builder => $query->where('is_active', true)),
SelectFilter::make('category')
->options(Category::all()->pluck('title', 'id')->toArray())->column('category_id')
];
}
protected function getTableActions(): array
{
return [];
}
protected function getTableBulkActions(): array
{
return [];
}
// protected function getTableRecordsPerPageSelectOptions(): array
// {
// return [10, 25, 50, 100];
// }
protected function isTablePaginationEnabled(): bool
{
return true;
}
public function render(): View
{
return view('livewire/list-post');
}
}
Thanks! This was a breaking change caused by #702.
The bugs are fixed in the latest update.
As for the request about adding other parameters to the query string - this would be a breaking change for people with multiple tables on the same page, so IMO it should be opt-in. At the moment, since $tableRecordsPerPage
, $tableSearchQuery
etc are all Livewire properties, you can just use Livewire's query string features to bind these properties to the URL.
Package
filament/tables
Package Version
v2.4.38
Laravel Version
v8.73.2
Livewire Version
v2.7.2
PHP Version
8.0.5
Bug description
It seems that you can't use pagination while filtering, clicking a pagination link seems to clear the filter.
Additionally it seems you can only use one filter at a time.
I also don't really understand why the pagination updates the url, but the per page options do not. I think the filters and search should also update the url.
It also appears that searching also resets the filters, but searching does work correctly with pagination.
Steps to reproduce
No response
Relevant log output
No response