#How to implement action or trigger event after reordering rows in a table
1 messages · Page 1 of 1 (latest)
I got the same question.
@stray owl 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:
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
);
I think this helps only to customize the button that enable reordering. Am I wrong?
1s
use Filament\Tables\Actions\Action;
// ....
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->action(function () {
if (! $isReordering){
// Do something
}
})
->button()
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
);
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 start
Then 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:
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->after(function () {
})
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
);
Try using the $isReordering inside the after()
We are quite there
->reorderRecordsTriggerAction(
fn (TableAction $action, bool $isReordering) => $action
->button()
->after(function ($isReordering) {
if (! $isReordering) {
CalculateRegistrationPointsByPosition::make('CalculateRegistrationPointsByPosition');
}
})
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
)
With this code reordering default behavior works but it seems that this action is not executed:
CalculateRegistrationPointsByPosition::make('CalculateRegistrationPointsByPosition');
Yeah, then I think it just doesn't work :/
I also tried to simplify omitting $isRecording logic:
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->after(function () {
CalculateRegistrationPointsByPosition::make('CalculateRegistrationPointsByPosition');
})
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
)
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