F
Filamentβ€’13mo ago
PANC

Filament Table column hidden with condition

I have this two columns: TextColumn::make('column_one') ->sortable(), TextColumn::make('column_two') ->sortable() ->searchable(), If column_one equals to 1, then hide column_one and show column_two If column_one different from 1, then hide column_two
4 Replies
PANC
PANCOPβ€’13mo ago
Thank you for replying πŸ™‚ And with this state() function, how can i trigger the hide() for current element or any other element?
Tieme
Tiemeβ€’13mo ago
What Leandro means is
TextColumn::make('column_one')
->state(function (Model $record): string{
if($record->column_one == 1){
return $record->column_two;
}
return $record->column_one;
}),
TextColumn::make('column_one')
->state(function (Model $record): string{
if($record->column_one == 1){
return $record->column_two;
}
return $record->column_one;
}),
Only don't use sortable, because that is not gonna work.
PANC
PANCOPβ€’13mo ago
Thank you @Leandro Ferreira and @Tieme This solves one of my problems πŸ™‚ Thank you πŸ˜„ Will mark as solved
Want results from more Discord servers?
Add your server