#table layout styling

32 messages · Page 1 of 1 (latest)

olive umbra
#

So whenever I implement layout functionality such as Split or stack. The entire table just keels over.

            ->columns([
                Tables\Columns\TextColumn::make('id')
                    ->label('ID')
                    ->toggleable(isToggledHiddenByDefault: true)
                    ->searchable(),
                Tables\Columns\Layout\Stack::make([
                    Tables\Columns\TextColumn::make('name')
                        ->searchable(),
                    Tables\Columns\TextColumn::make('username')
                        ->toggleable(isToggledHiddenByDefault: true)
                        ->searchable(),
                ]),
                Tables\Columns\TextColumn::make('email')
                    ->searchable(),
                Tables\Columns\TextColumn::make('email_verified_at')
                    ->dateTime()
                    ->toggleable(isToggledHiddenByDefault: true)
                    ->sortable(),
                Tables\Columns\TextColumn::make('status')
                    ->badge(),
                Tables\Columns\TextColumn::make('roles')
                    ->formatStateUsing(function ($record) {
                        return $record->roles->pluck('name')->join(', ');
                    })
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('dt_last_logged_in')
                    ->dateTime()
                    ->toggleable(isToggledHiddenByDefault: true)
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])

Example

kind lintelBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

olive umbra
#

It should only stack the name and username fields?

Also all toggleable columns dont seem to have its functionality when using Stack, Split etc

olive umbra
#

Another example, where it's just all over and messy

            ->columns([
                Tables\Columns\Layout\Split::make([
                    Tables\Columns\Layout\Stack::make([
                        Tables\Columns\TextColumn::make('name')
                            ->icon('heroicon-o-identification')
                            ->searchable(),
                        Tables\Columns\TextColumn::make('email')
                            ->icon('heroicon-o-envelope')
                            ->searchable(),
                    ]),

                    Tables\Columns\TextColumn::make('status')
                        ->badge(),
                    Tables\Columns\TextColumn::make('roles')
                        ->formatStateUsing(function ($record) {
                            return $record->roles->pluck('name')->join(', ');
                        })
                        ->toggleable(isToggledHiddenByDefault: true),
                    Tables\Columns\TextColumn::make('dt_last_logged_in')
                        ->dateTime()
                        ->toggleable(isToggledHiddenByDefault: true)
                        ->sortable(),
                ])->from('md'),

            ])

Nothing is aligned

dawn trench
#

@olive umbra Did you manage to figure this out?

silver perch
#

Not aligned how?

dawn trench
#

you can see in the last screenshot, columns are not aligned, i have similiar results

silver perch
dawn trench
#

@silver perch i tried this as well, however it creates alot more work to get everything right and its breaks other things such as ->defaultSort('name').

Is there no other options for a simple stack just to get 2 columns stacked vertically?

silver perch
dawn trench
#

if you dont want to go through that post the final solution was

silver perch
#

Hmm, I’m surprised that ever worked because it would create an invalid html structure.

dawn trench
#

oh i actually just got it to work

#

it makes the row very long though

silver perch
#

But you could do that with formatStateUsing() and returning either p tags or just a string with br tags.

#

I wouldn’t nest actual columns like in the issue though.

dawn trench
#

ok will look into that, thanks.

I am currently moving over from Nova to Filament and so far this is the only thing that was more friendly on Nova. you can just Stack::make anywhere in your table

silver perch
#

Nesting the columns would put td tags inside td tags which isn’t valid html and would lead to accessibility issues.

silver perch
dawn trench
#

yeah i am seeing that, would be cool to have it available as a column type

#

but thanks for your advise 👍

silver perch
#

Probably a lot easier in nova since it’s vue. So no heavy rerendering on the livewire side.

dawn trench
#

right, that makes sense

#

@silver perch did you mean something like this? i had to use getStateUsing because formatStateUsing isnt working for some reason.

            TextColumn::make('customer_details')
                ->label('Test')
                ->getStateUsing(fn ($record) => "{$record->model_number} <br> {$record->status}")
                ->html(),
silver perch
dawn trench
#

all good, Thanks 👍

silver perch
#

Did that work for you?

dawn trench
#

yeah its the best solution i have tried so far

silver perch