FilamentF
Filament16mo ago
F alko

Format state on empty column

I have table with width, height and length parameters.
When showing this in the table, I want to add a size column That shows width x height x length.

Tables\Columns\TextColumn::make('width')
    ->label('Size')
    ->formatStateUsing(fn($record) => sprintf(
        '%s x %s x %s mm',
        $record->width ?? '?',
        $record->height ?? '?',
        $record->length ?? '?',
    ),
),

However, when one is null, I want to show ? instead. When width is null, it doesn't hit the formatStateUsing method.

Is there a way to make a virtual column that is always resolved?
Was this page helpful?