F
Filamentβ€’4w ago
toeknee

Widget Charts action points to filter table?

Has anyone successfully make the clickable points on a chart filter the list page table?
6 Replies
gladjanus43
gladjanus43β€’4w ago
not in a chart, i did with a stats widget though but dont know how different they are πŸ˜…
toeknee
toekneeOPβ€’4w ago
Hmmm stats might work depending how you did it?
gladjanus43
gladjanus43β€’3w ago
Sorry! Did you figure it out? in the ListPage of your resource you can add
#[On('updateStatusFilter')]
public function updateFilters(string $status, string $filter): void
{
// dd($this->tableFilters);
$this->tableFilters[$filter]['value'] = $status;
$this->updatedTableFilters();
}
#[On('updateStatusFilter')]
public function updateFilters(string $status, string $filter): void
{
// dd($this->tableFilters);
$this->tableFilters[$filter]['value'] = $status;
$this->updatedTableFilters();
}
Then in your widget:
Stat::make('Shifts in draft', Shift::where('status', ShiftStatus::DRAFT)->count())
->extraAttributes([
'class' => 'cursor-pointer',
'wire:click' => "\$dispatch('updateStatusFilter', { status: 'DRAFT', filter: 'status'})",
]),
Stat::make('Shifts in draft', Shift::where('status', ShiftStatus::DRAFT)->count())
->extraAttributes([
'class' => 'cursor-pointer',
'wire:click' => "\$dispatch('updateStatusFilter', { status: 'DRAFT', filter: 'status'})",
]),
toeknee
toekneeOPβ€’3w ago
This would be neat to add to filament tips and tricks. and looks good! I might be able to add the wire click into the graph... but we will see.
gladjanus43
gladjanus43β€’3w ago
Jeah I found it somewhere online allready! Let me check if I can find it. Think it was from filament-daily or something Let me know, i am curious!
gladjanus43
gladjanus43β€’3w ago
https://laraveldaily.com/post/filament-click-widget-auto-update-table-filter here it is, just needed to update to dispatch because it was written for v2
Want results from more Discord servers?
Add your server