F
Filament9mo ago
Mina

Filament widget on click show table list record

Is it possible to make the widget clickable so that when you click it, it redirects you to a resource page. I am talking about dashboard widget. If it is possible, can someone please provide me with an example so that I can then modify it to suit my needs. Also if someone has an example where you click a widget, for example Active shops, and it renders a list of only active shops
3 Replies
Dennis Koch
Dennis Koch9mo ago
It’s possible but I don’t have the code right now. Look for some method containing url on the widget
Mina
MinaOP9mo ago
I actually made it work using ->extraAttributes([ 'class' => 'cursor-pointer', 'wire:click' => "redirectTo('filament.control.resources.funnels.index')", ]), forgot to update the chat, but if this helps anyone great 😁
Mokatchi
Mokatchi2w ago
Hello @Mina I'm looking forward the same concept. So can you please tell me where you added the extra attributes? In my case I was working like this, but I coudn't have any result.
protected function getType(): string
{
return 'doughnut';
}

protected function getOptions(): array
{
return [
'scales' => [
'x' => [
'display' => false,
],
'y' => [
'display' => false,
],
],
'plugins' => [
'legend' => [
'onClick' => 'handleClick',
]
]
];
}

public function handleClick($segmentIndex): void
{
dd( 'i am clicked!!! ');
// $statuses = ['not_launched', 'in_progress', 'finished'];
// $status = $statuses[$segmentIndex];

// $url = ProjProgResource::getUrl('index', [
// 'status' => $status,
// ]);

// redirect($url)->send();
}
protected function getType(): string
{
return 'doughnut';
}

protected function getOptions(): array
{
return [
'scales' => [
'x' => [
'display' => false,
],
'y' => [
'display' => false,
],
],
'plugins' => [
'legend' => [
'onClick' => 'handleClick',
]
]
];
}

public function handleClick($segmentIndex): void
{
dd( 'i am clicked!!! ');
// $statuses = ['not_launched', 'in_progress', 'finished'];
// $status = $statuses[$segmentIndex];

// $url = ProjProgResource::getUrl('index', [
// 'status' => $status,
// ]);

// redirect($url)->send();
}
Want results from more Discord servers?
Add your server