table filters update event
Unfortunately I haven't found a good way yet to listen on table form filter change events.
I have the table filters: startDate and endDate and want to listen on the component above the tablefilter when one of the field gets changed.
Is there an easy way to emit specific events from a form filter? like: ->emitEvent({name}, ..) or something.
Or is there a predefined event?
Same goes for the reverse way: Emit an event from the parent component and listen to the events in the filament table and change some filter values when a specific event occurs.
Solution:Jump to solution
Since your asking about v2, for the reverse way check out this link: https://laraveldaily.com/post/filament-click-widget-auto-update-table-filter
For filters to the other component, you might be able to overwrite updatedTableFilters() on your ListResource and add an emitter there, and then listen on your other component. On my phone but that makes sense in my mind....
Laravel Daily
Filament: Click on Widget - Auto-Update Table Filter
3 Replies
I'm actually working on a similar issue right now.
I think you can just $dispatch() and use
On
https://discord.com/channels/883083792112300104/1144726440877772841 maybe helpful to youSolution
Since your asking about v2, for the reverse way check out this link: https://laraveldaily.com/post/filament-click-widget-auto-update-table-filter
For filters to the other component, you might be able to overwrite updatedTableFilters() on your ListResource and add an emitter there, and then listen on your other component. On my phone but that makes sense in my mind.
Laravel Daily
Filament: Click on Widget - Auto-Update Table Filter
Thanks both for your answers. Really appreciate it.
I will check the supposed links out and see how far I come π
Since your asking about v2, for the reverse way check out this link: https://laraveldaily.com/post/filament-click-widget-auto-update-table-filterthis one works like charm. Implemented it in 5 minutes.
public function updatedTime()
{
$this->setDates($this->time);
$this->statisticData = GenerateAccountingDocumentStatistic::run($this->startDate, $this->endDate);
$this->emit("filterUpdate", ['startDate' => $this->startDate, 'endDate' => $this->endDate]);
}
just used the emit function of the updatedTime watch method.
And added the listener to the Invoices Table as suggested
reverse way also works with the suggested overwrite of updatedTableFilters()
thanks!!