How to update Relation Manager table data

I need to create an action that when clicked it updates the relation manager table where this action is located. Which method should I call within the action to do this? Thanks
No description
Solution:
The action is on the relation manager itself? If so, action should dispath an event
Tables\Actions\Action::make('refresh')
->dispatchSelf('refreshComments'),
Tables\Actions\Action::make('refresh')
->dispatchSelf('refreshComments'),
...
Jump to solution
19 Replies
Expecto Patronum
public function isReadOnly(): bool { return false; } Add this code in your relation manager file
joao nivaldo
joao nivaldoOP4w ago
Thanks for the suggestion, but I don't think I explained what I wanted well. I need that when the user clicks on the REFRESH button it triggers an action that will read the relationship and display the data in the table below the button. Something like $this->relation-manger->refresh(). then the table will be updated. Thanks
toeknee
toeknee4w ago
Why not just add polling? Otherwise I have seen the option using attrbutes for On methods to refresh
joao nivaldo
joao nivaldoOP4w ago
How would I add POLLING? Using the ON method would be nice, but all the examples I found only refresh the OWNER table builder of the relation-manager. If you could give me an example of how I would do it to refresh only the relation, I would appreciate it. Thanks.
Solution
krekas
krekas3w ago
The action is on the relation manager itself? If so, action should dispath an event
Tables\Actions\Action::make('refresh')
->dispatchSelf('refreshComments'),
Tables\Actions\Action::make('refresh')
->dispatchSelf('refreshComments'),
and then you listen for this event on the relation manager class and refresh
#[On('refreshComments')]
public function refresh(): void
{}
#[On('refreshComments')]
public function refresh(): void
{}
joao nivaldo
joao nivaldoOP3w ago
Hi, I did this but instead of using dispatchSelf I used after. I imagine it's similar. When I include a product in the relationship, it updates the page without any problems, but when I dispatch it in the relationship pipeline, it doesn't update at all. It goes through the refresh method and executes $this->formFill() but doesn't update the page. Do you know what it could be?
krekas
krekas3w ago
I don't understand your problem
joao nivaldo
joao nivaldoOP3w ago
I have a page that has a relationship on it. When I include or delete an item in the relationship it has to update the values ​​in the parent form of the relationship on this page. And this is only happening when I include the item and when I remove it it is not updating the fields. I will send the images for you to see.
joao nivaldo
joao nivaldoOP3w ago
This image was when I included a new item in the relationship and it correctly updated the values ​​that are in red.
No description
joao nivaldo
joao nivaldoOP3w ago
Now I removed the item and see that it notified everything but did not change the values ​​that are in red.
No description
joao nivaldo
joao nivaldoOP3w ago
Then when I click on the save and recalculate button it changes the values ​​correctly
No description
joao nivaldo
joao nivaldoOP3w ago
These values ​​in red are values ​​that come from the table and are not editable.
krekas
krekas3w ago
Because you don't refresh them on the action. Hard to tell without code
joao nivaldo
joao nivaldoOP3w ago
Hello, This is the action code for both include and remove.
No description
krekas
krekas3w ago
And what's the problem? Listen for them on the proper class
joao nivaldo
joao nivaldoOP3w ago
No description
joao nivaldo
joao nivaldoOP3w ago
This action is on the editpage. Do I have to put it on the ListPage or ResourcePage for the deletion to work?
krekas
krekas3w ago
On the page where it should be refreshed
joao nivaldo
joao nivaldoOP3w ago
On which page should I put the Delete on to work? since it is currently on the Edit Page and works fine, but it does not work on the Delete. Although it is being called correctly upon deletion, see the notification appearing in the deletion image. It just doesn't update.
Want results from more Discord servers?
Add your server