Refresh TableWidget data after Action
I have a TableWidget in a View that queries certain data related to the information in the view.
Each row has an action that performs an attach in a relationship which would make that row to not be shown in that same widget as a result. E.g: if I perform the same query again refreshing the page, that row would not appear there.
The thing is that, I can’t make the data of the table refresh itself to (effectively) hide the row where I just clicked the action.
I saw in the documentation that if you change values of that row with the action, the row data should update instantly with livewire, but seems to not be working in case of the row having to disappear.
If that’s not an option, I would like to refresh the whole table performing the original query again, which would have the intended effect.
I tried calling the resetTable() on the Livewire component, but it doesn’t seem to do anything, so I guess it’s not the correct approach.
I don’t think it matters, but the data refresh would be performed just after sending a notification to the user, which I have in the ‘after’ method of the Action inside a function. In the same function is where I added the resetTable() after the notification.
Any ideas? Thanks!
Each row has an action that performs an attach in a relationship which would make that row to not be shown in that same widget as a result. E.g: if I perform the same query again refreshing the page, that row would not appear there.
The thing is that, I can’t make the data of the table refresh itself to (effectively) hide the row where I just clicked the action.
I saw in the documentation that if you change values of that row with the action, the row data should update instantly with livewire, but seems to not be working in case of the row having to disappear.
If that’s not an option, I would like to refresh the whole table performing the original query again, which would have the intended effect.
I tried calling the resetTable() on the Livewire component, but it doesn’t seem to do anything, so I guess it’s not the correct approach.
I don’t think it matters, but the data refresh would be performed just after sending a notification to the user, which I have in the ‘after’ method of the Action inside a function. In the same function is where I added the resetTable() after the notification.
Any ideas? Thanks!
Solution
Okay, finally did it dispatching a livewire event and adding a map to $refresh in the $listeners.