F
Filament2y ago
DeDe

Make row from panel conditionnaly collapsible

I'm trying to make row from panel in table conditionally collapsible when the closure return true (record return count > 0 on relationship) from this code. But a modification in filament is needed and i'm stuck (see screenshot) Help !
public static function table(Table $table): Table
{
return $table
->columns([
Split::make([
TextColumn::make('test.id')->label('idtest'),
TextColumn::make('test1')->label('test1'),
]),
Panel::make([
Stack::make([
//TextColumn::make('details.test_id')->label('testid'),
TextColumn::make('details.detail1')->label('detail1'),
TextColumn::make('details.detail2')->label('detail2'),
TextColumn::make('details.detail3')->label('detail3'),
])->collapsible( function(Model $record){
if($record->details()->count() > 0) {
return true;
}
else {
return false;
}
}),
])
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Split::make([
TextColumn::make('test.id')->label('idtest'),
TextColumn::make('test1')->label('test1'),
]),
Panel::make([
Stack::make([
//TextColumn::make('details.test_id')->label('testid'),
TextColumn::make('details.detail1')->label('detail1'),
TextColumn::make('details.detail2')->label('detail2'),
TextColumn::make('details.detail3')->label('detail3'),
])->collapsible( function(Model $record){
if($record->details()->count() > 0) {
return true;
}
else {
return false;
}
}),
])
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
2 Replies
DeDe
DeDeOP2y ago
I want to hide the arrow too when my condition is false (and make collapsible false) I want using Split component as "headers" and panel component as conditionnaly collapsible row to see details of a record
toeknee
toeknee2y ago
I cannot see how you would easily do that given it's collapsible or it's not as a whole. You either have collapsible table or not. Collapsible is a div table opposed to the normal tables based approach
Want results from more Discord servers?
Add your server