F
Filamentβ€’15mo ago
krizz3332

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:
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....
Jump to solution
3 Replies
sm
smβ€’15mo ago
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 you
Solution
Kenneth Sese
Kenneth Seseβ€’15mo ago
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.
krizz3332
krizz3332OPβ€’15mo ago
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-filter
this 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!!
Want results from more Discord servers?
Add your server