F
Filamentβ€’2mo ago
christmex

Refresh table widget in dashboard after success create record using action

How can i achieve to refresh the table only after i create record using action, i mean, i can using poll in my table widget but, its kinda annoying when u always request, so i think that would be better its only update after i success create the record via modal action thank you.
3 Replies
ChesterS
ChesterSβ€’2mo ago
If you create a record through an action on the table, it should refresh automatically πŸ€” If not, you could dispatch an event and listen for it in the table page/component. Something like $this->dispatch('something-created') and then listen for that event with #[On('something-created')] on top of the class
christmex
christmexβ€’2mo ago
no it dont, as i said, im using Action. not table action, so in my dashboard, i use extend the dashboard and add the getHeaderActions and put the action over there, and not table action, also the name space using
Filament\Actions\Action
Filament\Actions\Action
then i create table-widget, so when i run the action from dashboard file i want the table-widget refresh, but as default it doesnt, i already try the dispact way before, but still same πŸ˜ŠπŸ™. i can achieve to refresh the table using poll, but still, im feeling it just not right, or maybe thats the way but im not sure about it, so if there is another way to achieve i mean the good way, thats wht im looking for... anyways, thank for ur answer man
ChesterS
ChesterSβ€’2mo ago
An event should work. If you dispatch an event and put either
#[On('my-event')]
class MyCostomComponent extends Component
#[On('my-event')]
class MyCostomComponent extends Component
it should refresh the table. (there are other ways to achieve this but this is pretty simple/straightforward)