getHEaderWidgetColumns not works in resource view

In my resource view, i have a stats widget wit 5 boxes divided in 2 rows 3 and 2 i want 5 block in a row, so i added getHeaderWidgetsColumns() to my widget but it doens't works i want 5 columns only for this widget not for the otherd `` <?php namespace App\Filament\Resources\RepairResource\Widgets; use Filament\Widgets\StatsOverviewWidget as BaseWidget; use Filament\Widgets\StatsOverviewWidget\Stat; class RepairOverview extends BaseWidget { public function getHeaderWidgetsColumns(): int | array { return 5; } protected function getStats(): array { $quote = 165; $paid = 175; $costs = 120; $profit = $quote - $costs; $finalProfit = $paid - $costs; return [ Stat::make('Preventivo', $quote) , Stat::make('Incasso', $paid), Stat::make('Costi', $costs), Stat::make('Utile previsto', $profit), Stat::make('Utile effettivo', $finalProfit) ->description('7% decrease'), ]; } } ```
2 Replies
awcodes
awcodes7mo ago
Looking at the code. I don’t think you can change the columns on a stats overview widget. You might have to make a custom one.
undercode
undercode6mo ago
You can use protected function getColumns(): int, but it only allows you 4 columns max. If you need more columns you can create your own view based on stats-overview-widget.blade.php and modify it to add more column options. Mine is:
@php
$columns = $this->getColumns();
@endphp

<x-filament-widgets::widget class="fi-wi-stats-overview">
<div
@if ($pollingInterval = $this->getPollingInterval())
wire:poll.{{ $pollingInterval }}
@endif
@class([
'fi-wi-stats-overview-stats-ctn grid gap-6',
'md:grid-cols-1' => $columns === 1,
'md:grid-cols-2' => $columns === 2,
'md:grid-cols-3' => $columns === 3,
'md:grid-cols-2 xl:grid-cols-4' => $columns === 4,
'md:grid-cols-3 xl:grid-cols-5' => $columns === 5,
'md:grid-cols-3 xl:grid-cols-6' => $columns === 6,
])
>
@foreach ($this->getCachedStats() as $stat)
{{ $stat }}
@endforeach
</div>
</x-filament-widgets::widget>
@php
$columns = $this->getColumns();
@endphp

<x-filament-widgets::widget class="fi-wi-stats-overview">
<div
@if ($pollingInterval = $this->getPollingInterval())
wire:poll.{{ $pollingInterval }}
@endif
@class([
'fi-wi-stats-overview-stats-ctn grid gap-6',
'md:grid-cols-1' => $columns === 1,
'md:grid-cols-2' => $columns === 2,
'md:grid-cols-3' => $columns === 3,
'md:grid-cols-2 xl:grid-cols-4' => $columns === 4,
'md:grid-cols-3 xl:grid-cols-5' => $columns === 5,
'md:grid-cols-3 xl:grid-cols-6' => $columns === 6,
])
>
@foreach ($this->getCachedStats() as $stat)
{{ $stat }}
@endforeach
</div>
</x-filament-widgets::widget>
Want results from more Discord servers?
Add your server