[Feature Request] The ability to "stack" columns in a traditional table (not inside a split) #12061
Replies: 3 comments
-
I'm also looking for same solution. This seems to be achieved in the screenshot provided in the filament docs but how it is done through code is not mentioned. |
Beta Was this translation helpful? Give feedback.
-
I did a workaround for this while waiting for an official method. Basically using the return $table
->columns([
ImageColumn::make('avatar'),
TextColumn::make('name'),
TextColumn::make('contacts'),
->state(fn (Model $record): array => [
TextColumn::make('phone')->record($record)->icon('heroicon-m-phone')->toHtml(),
TextColumn::make('email')->record($record)->icon('heroicon-m-envelope')->toHtml(),
])
->listWithLineBreaks()
->formatStateUsing(fn ($state): HtmlString => new HtmlString($state)), // or ->html()
]) Important things here are:
First, setting the column record with the inherited record. Without doing this, the column would just contains nothing. Second, we need to render the column directly to html as I mentioned above with To get rid of the padding on each the column, you can apply the Hope that helps! :) Refs: |
Beta Was this translation helpful? Give feedback.
-
Actually, I found that you didn't need to format them as html. return $table
->columns([
ImageColumn::make('avatar'),
TextColumn::make('name'),
TextColumn::make('contacts'),
->state(fn (Model $record): array => [
TextColumn::make('phone')->record($record)->icon('heroicon-m-phone'),
TextColumn::make('email')->record($record)->icon('heroicon-m-envelope'),
])
->listWithLineBreaks()
]) So, the important things are just setting the column record and From there, you may customize the column as you wish. |
Beta Was this translation helpful? Give feedback.
-
I was looking for a way to stack columns like seen here: https://demo.filamentphp.com/blog/authors but without using a split.
A split removes the headers on the table which I still require. I would expect it would take a
label()
method since it wouldn't be able to infer the header. Something like this:I understand this can be achieved on a single
TextColumn
using the->listWithLineBreaks()
method. However, this requires a convoluted accessor defined on the model if you want to do anything fancy like include icons or change styling.Beta Was this translation helpful? Give feedback.
All reactions