F
Filamentβ€’8mo ago
Harvey

Custom table columns per table tab

I'm moving from Nova, and basically want to replicate what a Lense does in Filament. So when I switch to my "Pending Payments" tab, I want to also add a column showing "payment total". Is this at all possible? Or do I need to have separate pages/tables linked to these tabs?
Solution:
So the filament version of a lens would be using filter tabs on the "ListRecords" page class: https://filamentphp.com/docs/3.x/panels/resources/listing-records#using-tabs-to-filter-the-records On your columns you can use a callback in hidden() to inject $livewire which will give you the instance of ListRecords, you can then use that to check the current tab. Let's say you have the following on the ListRecords page:...
Jump to solution
3 Replies
toeknee
toekneeβ€’8mo ago
Welcome to the Darkside! So it is possible, you can custom code it or just use a premium plugin.... https://filamentphp.com/plugins/kenneth-sese-advanced-tables#toggling-and-reordering-columns-new
Filament
Advanced Tables (formerly Filter Sets) by Kenneth Sese - Filament
Supercharge your tables with powerful features like user customizable views, enhanced filter tabs, reorderable columns, convenient view management, and more. Compatible with Resource Panel Tables, Relation Managers, Table Widgets, and Table Builder!
Solution
ConnorHowell
ConnorHowellβ€’8mo ago
So the filament version of a lens would be using filter tabs on the "ListRecords" page class: https://filamentphp.com/docs/3.x/panels/resources/listing-records#using-tabs-to-filter-the-records On your columns you can use a callback in hidden() to inject $livewire which will give you the instance of ListRecords, you can then use that to check the current tab. Let's say you have the following on the ListRecords page:
public function getTabs(): array
{
return [
'all' => Tab::make(),
'active' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('active', true)),
'inactive' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('active', false)),
];
}
public function getTabs(): array
{
return [
'all' => Tab::make(),
'active' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('active', true)),
'inactive' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('active', false)),
];
}
On a table you could do the following to make the 'active' column only show on the all tab:
Tables\Columns\IconColumn::make('active')
->boolean()
->hidden(fn ($livewire) => $livewire->activeTab !== 'all')
Tables\Columns\IconColumn::make('active')
->boolean()
->hidden(fn ($livewire) => $livewire->activeTab !== 'all')
Harvey
HarveyOPβ€’8mo ago
Awesome, thanks guys for the answers. I'll go with the custom code one for now, but that plugin definitely looks functionality packed.πŸ˜„
Want results from more Discord servers?
Add your server