How to implement action or trigger event after reordering rows in a table
I want to run some code after a user is done reordering how do i achieve this? is it even possible.
12 Replies
I got the same question.
@RichtheKid have you found a solutions?
kind of? You can check if a table is reordering with:
https://filamentphp.com/docs/3.x/tables/advanced#query-string
But I dont think that there is a function for it
I need to trigger an action when the user finish to reorder a table in a relation manager
or maybe from this callable:
I think this helps only to customize the button that enable reordering. Am I wrong?
1s
I havent tried this, but its a guess
Very interesting, I will try
->reorderRecordsTriggerAction(
fn (TableAction $action, bool $isReordering) => $action
->action(function ($isReordering){
if (! $isReordering) {
CalculateRegistrationPointsByPosition::make('CalculateRegistrationPointsByPosition');
}
}
)
->button()
->label($isReordering ? 'End reordering' : 'Reorder'),
)
I tried this implemetation adding $reordering var inside action function but it doesn't work
When I click Reorder nothing happen, reordering with drag & drop doesn't startThen its not possible atm. I asked Dan if I can make a PR for it, I will let you know if he agrees
actually
Try this:
Try using the $isReordering inside the after()
We are quite there
With this code reordering default behavior works but it seems that this action is not executed:
Yeah, then I think it just doesn't work :/
I also tried to simplify omitting $isRecording logic:
Doesn't work
Thanks a lot for your support 🫶🏻
It was my fault, my action was not correct
Now I need only a way to pass a parameter to a new function I just developed
I need to access $ownerRecord inside reorderRecordsTriggerAction()
it's working
in a very rough way but it works
Here is my full code: