F
Filament4mo ago
Vetlin

Table Collapsible Content - Keep Column Headers

Hello! I'm trying to create a collapsible rows but when I try to use this https://filamentphp.com/docs/3.x/tables/layout#collapsible-content table headers disappear. Is there any way to achieve collapsible rows and also keep table headers?
10 Replies
Abmael Souza
Abmael Souza4mo ago
you would have to make a custom view such as
public static function table(Tables\Table $table): Tables\Table
{
return $table
->columns([
TextColumn::make('id')->label('ID'),
TextColumn::make('name')->label('Name'),
TextColumn::make('email')->label('Email'),
])
->rowActions([
Tables\Actions\Action::make('view')
->label('View')
->icon('heroicon-o-eye')
])
->contentLayout([
Collapse::make('details') // Collapsible content
->content(function ($record) {
return view('partials.record-details', ['record' => $record]);
}),
]);
}
public static function table(Tables\Table $table): Tables\Table
{
return $table
->columns([
TextColumn::make('id')->label('ID'),
TextColumn::make('name')->label('Name'),
TextColumn::make('email')->label('Email'),
])
->rowActions([
Tables\Actions\Action::make('view')
->label('View')
->icon('heroicon-o-eye')
])
->contentLayout([
Collapse::make('details') // Collapsible content
->content(function ($record) {
return view('partials.record-details', ['record' => $record]);
}),
]);
}
and on the path resources/views/partials/record-details.blade.php with content such as
<div>
<p><strong>Additional Info:</strong> {{ $record->additional_info }}</p>
<p><strong>Created At:</strong> {{ $record->created_at }}</p>
</div>
<div>
<p><strong>Additional Info:</strong> {{ $record->additional_info }}</p>
<p><strong>Created At:</strong> {{ $record->created_at }}</p>
</div>
i hope that helped further than that i'm also helpless
Vetlin
VetlinOP4mo ago
But there is no contentLayout method on Table And also I can't find Collapse class
Abmael Souza
Abmael Souza4mo ago
could it be rowView then ? same pattern, but with ->rowView('tables.collapsible-row'); Create a blade file named collapsible-row.blade.php in resources/views/tables/.
Vetlin
VetlinOP4mo ago
There is a ->view method
Abmael Souza
Abmael Souza4mo ago
i was guessing the method try view with that last pattern instead of rowView, view('table.collapsible-row')
Abmael Souza
Abmael Souza4mo ago
there's this part of the documentation too
No description
Abmael Souza
Abmael Souza4mo ago
maybe don't use the split, try a combination of the past examples this thread might also help #Collapsible Content - Keep Column Headers
Vetlin
VetlinOP4mo ago
Hello! The view('table.collapsible-row') is not working at all, it is overwrites the default table view Any other ideas?
giuszeppe
giuszeppe5d ago
Did you find a solution eventually?
Dennis Koch
Dennis Koch4d ago
It's not supported by default. You'd probably need to overwrite quite some Blade views which is not recommended. When you have collapsible rows you don't use a traditional table layout anymore, therefore there are no table headers anymore

Did you find this page helpful?