F
Filamentβ€’5mo ago
ericmp

Add Button Action To TextColumn

Problem: Right now, in the events table, my users want to click the row to go to the edit page of the record. But there is a problem. I have this TextColumn, which has a url. So if the user clicks the row, but not clicking the text, it opens the TextColumn url.
Tables\Columns\TextColumn::make('user.name')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
}),
Tables\Columns\TextColumn::make('user.name')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
}),
So is confusing, because they havent clicked the text of that TextColumn, therefore they don't want to navigate to that TextColumn url, they want to navigate to edit the specified record. What I want: So i want to instead of all the TextColumn space, create a button inside of it, so it is clear that if the user clicks the button will go where the button points to. otherwise, will go to edit the clicked row. What I tried: I tried to change the ->url for ->action:
Tables\Columns\TextColumn::make('user.name')->action(Tables\Actions\Action::make('view_user')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
})),
Tables\Columns\TextColumn::make('user.name')->action(Tables\Actions\Action::make('view_user')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
})),
But then, when i click it, it doesn't do anything. If i instead of ->url I put:
->action(function () {
dd('hi');
})
->action(function () {
dd('hi');
})
but is not visible Question: Is there a way, without creating a custom col, to add an action in the textcolumn, making it visible & also making the ->url action to work?
Solution:
Maybe this works as an alternative for you: ->description(fn () => new HtmlString('<a class="hover:underline" href="test">Β» Go to page</a>'))...
No description
Jump to solution
6 Replies
ericmp
ericmpOPβ€’5mo ago
bump
Dennis Koch
Dennis Kochβ€’5mo ago
I don't think that feature exists yet. Action always are used for the whole cell.
Solution
Dennis Koch
Dennis Kochβ€’5mo ago
Maybe this works as an alternative for you: ->description(fn () => new HtmlString('<a class="hover:underline" href="test">Β» Go to page</a>'))
No description
ericmp
ericmpOPβ€’5mo ago
u mean it will exist? someone is working on it? πŸ”
Dennis Koch
Dennis Kochβ€’5mo ago
Nope. I mean: Nobody cared enough to PR it πŸ˜…
ericmp
ericmpOPβ€’5mo ago
πŸ˜› its fine, thanks dennis ^^
Want results from more Discord servers?
Add your server