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?
8 Replies
Abmael Souza
Abmael Souza4w 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
VetlinOP4w ago
But there is no contentLayout method on Table And also I can't find Collapse class
Abmael Souza
Abmael Souza4w 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
VetlinOP4w ago
There is a ->view method
Abmael Souza
Abmael Souza4w ago
i was guessing the method try view with that last pattern instead of rowView, view('table.collapsible-row')
Abmael Souza
Abmael Souza4w ago
there's this part of the documentation too
No description
Abmael Souza
Abmael Souza4w 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
VetlinOP3w ago
Hello! The view('table.collapsible-row') is not working at all, it is overwrites the default table view Any other ideas?

Did you find this page helpful?