FilamentF
Filament3y ago
Vp

table column visibility base on record

I am trying to set the table column visibility base on some record, but it's showing error Argument #1 ($record) must be of type App\Models\Candidate, null given

What I've tried:
Tables\Columns\TextColumn::make('name')
    ->visible(fn (Candidate $record): bool => $record->is_complete) // is_complete is boolean column

But the same function for ->visible() is working fine in actions
My code which is working for action:
Tables\Actions\ViewAction::make()
    ->visible(fn (Candidate $record): bool => $record->is_complete),

So, what should be the error here?
Solution
This was asked quite some times here. You cannot hide table columns based on a record, because that would result in a bad table layout.
Was this page helpful?