F
Filament9mo ago
Mina

Widget getColumns not working

So, I've made a custom dashboard that has widgets. My issue is, it's not overwriting the default getcolumns() method. I want to have 3 widgets in a row (or more). this is my code: <?php namespace App\Filament\Pages; use App\Filament\Resources\FunnelResource\Widgets\FunnelOverview; use App\Filament\Resources\ShopResource\Widgets\ShopOverview; class Dashboard extends \Filament\Pages\Dashboard { public function getColumns(): int | string | array { return 3; } public function getHeaderWidgets(): array { return [ ShopOverview::class, FunnelOverview::make(['title' => 'Total Funnels']), FunnelOverview::make(['title' => 'Total Active Funnels']), FunnelOverview::make(['title' => 'Total Draft Funnels']), FunnelOverview::make(['title' => 'Total Paused Funnels']), ]; } } I've put the image of how it is looking, the widgets have colspan set to 1. Please help I am at total loss here
No description
5 Replies
Mina
MinaOP9mo ago
please help, I don't understand why is it not working thanks guys, it was the getHeaderWidgetsColumns(). Sometimes it takes 5 minutes of your time to help someone not have a panic attack actually, that one works only if the colspan of the widget is set to 1, and it doesn't look good
Mina
MinaOP9mo ago
No description
toeknee
toeknee9mo ago
You need to set the columnspan ojn your stats widget to be full
Gush
Gush8mo ago
help i did the same and its not working
<?php

namespace Norlogic\NlmnCustomerModule\Resources\CustomerResource\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Norlogic\NlmnCustomerModule\Models\Customer;

class CustomerCountOverview extends BaseWidget
{
protected function getStats(): array
{
return [
Stat::make(__('nlmn-customer-module::customer.customer_resource.total'), Customer::all()->count())
->chart([7, 2, 10, 3, 15, 4, 17])
->color('primary'),
];
}

public function getColumnSpan(): int | string | array
{
return 1;
}

protected int|string|array $columnSpan = 'full';

protected static ?int $sort = -1;

protected static bool $isLazy = false;
}
<?php

namespace Norlogic\NlmnCustomerModule\Resources\CustomerResource\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Norlogic\NlmnCustomerModule\Models\Customer;

class CustomerCountOverview extends BaseWidget
{
protected function getStats(): array
{
return [
Stat::make(__('nlmn-customer-module::customer.customer_resource.total'), Customer::all()->count())
->chart([7, 2, 10, 3, 15, 4, 17])
->color('primary'),
];
}

public function getColumnSpan(): int | string | array
{
return 1;
}

protected int|string|array $columnSpan = 'full';

protected static ?int $sort = -1;

protected static bool $isLazy = false;
}
protected int | string | array $columnSpan = 1;

protected function getColumns(): int
{
return 1;
}
protected int | string | array $columnSpan = 1;

protected function getColumns(): int
{
return 1;
}
SOLUTION
Adnan Yalahow
Adnan Yalahow4mo ago
hi is there any way i can change how stats are dispalyed based on size of the screen in getColumns() like this
public function getColumns(): int | string | array
{
return [
'md' => 4,
'xl' => 5,
];
}
public function getColumns(): int | string | array
{
return [
'md' => 4,
'xl' => 5,
];
}
the funtion return type is only int now
Want results from more Discord servers?
Add your server