F
Filament6mo ago
MAF

I want to generate dynamic ExportColumn!

Is there anyway to access $record inside getColumns(), in my case, I want to generate dynamic ExportColumn! i.e., if I have a JSON field, I want to break it down to multiple columns while exporting.
1 Reply
nanopanda
nanopanda6mo ago
Yes, you can access $record in the ->formatStateUsing closure. For example:
ExportColumn::make('tags')
->formatStateUsing( function (Customer $record ): string {
return $record->tags?->pluck('name')->implode(',');
}),
ExportColumn::make('tags')
->formatStateUsing( function (Customer $record ): string {
return $record->tags?->pluck('name')->implode(',');
}),

Did you find this page helpful?