F
Filament16mo ago
Thijmen

StatsWidget column count

Is there any way to make the grid 2 cols? In the source code there is this:
'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-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,
But if i look at $columns count there is no way to make it 2:
protected function getColumns(): int
{
$count = count($this->getCachedStats());

if ($count < 3) {
return 3;
}

if (($count % 3) !== 1) {
return 3;
}

return 4;
}
protected function getColumns(): int
{
$count = count($this->getCachedStats());

if ($count < 3) {
return 3;
}

if (($count % 3) !== 1) {
return 3;
}

return 4;
}
8 Replies
DrByte
DrByte16mo ago
Yes: just override the method itself:
protected function getColumns(): int
{
return 2;
}
protected function getColumns(): int
{
return 2;
}
Thijmen
ThijmenOP16mo ago
Thanks
Thijmen
ThijmenOP15mo ago
Should be in the widgets docs tbh Because that page is not for widgets
DrByte
DrByte15mo ago
I understand your point. I think the reason for documenting it in the Dashboards area is because it's in Dashboards/panels that you actually "display" the widget. The Widgets directory of docs is more about "making" widgets, not displaying them.
Thijmen
ThijmenOP15mo ago
I get you. But widgets are not restricted to a dashboard page You can put them on any page
DrByte
DrByte15mo ago
Fair. I'm sure that a reasonable proposal as a PR to the docs would be welcomed.
Thijmen
ThijmenOP15mo ago
Yeah will think about it
Want results from more Discord servers?
Add your server