F
Filamentβ€’2y ago
Crylar

Is it possible to change action on row click?

I was wondering if it's possible to trigger another action when user clicks on a row? e.g. I would like to have view action instead of edit action on row click.
10 Replies
Brian Kidd
Brian Kiddβ€’2y ago
Check the docs
Dan Harrin
Dan Harrinβ€’2y ago
if you have a ViewAction defined in the table we will use that one by default anyway
Crylar
CrylarOPβ€’2y ago
Hm, I did not but I will try. I did not think about it. πŸ™‚ Is there a way to have view open as modal? Right now it opens as a separate page.
toeknee
toekneeβ€’2y ago
Remove the linkage to the table with the page class
Dennis Koch
Dennis Kochβ€’2y ago
Don't have a ViewPage and it will open in a modal
Crylar
CrylarOPβ€’2y ago
What about opening a modal on row clicking? I am in a chicken and egg race here. I thought I can use view as a modal when user clicks on a row but then view does not allow to edit anything, and I have some toggle actions that I want to allow user to change.
Dennis Koch
Dennis Kochβ€’2y ago
You can overwrite the row action on the List Page. Something like getRowRecordAction or similar
Crylar
CrylarOPβ€’2y ago
php
protected function getTableRecordActionUsing(): ?Closure
{
return fn (): string => 'view';
}
php
protected function getTableRecordActionUsing(): ?Closure
{
return fn (): string => 'view';
}
So I have managed to override this using but for this I need to remove
'edit' => Pages\EditOrder::route('/{record}/edit'),
'edit' => Pages\EditOrder::route('/{record}/edit'),
The problem now is that when I click edit button, the edit opens in a modal.
Dan Harrin
Dan Harrinβ€’2y ago
you need an edit page defined in the getPages()
Crylar
CrylarOPβ€’2y ago
yeh but then getTableRecordActionUsing is not working anymore, when I click on row it opens in edit
protected function getTableRecordActionUsing(): ?Closure
{
return fn (): string => 'view';
}

protected function getTableRecordUrlUsing(): ?Closure
{
return null;
}
protected function getTableRecordActionUsing(): ?Closure
{
return fn (): string => 'view';
}

protected function getTableRecordUrlUsing(): ?Closure
{
return null;
}
Okay, this works. πŸ™‚
Want results from more Discord servers?
Add your server