Select Table record for bulk action on click
I want to select a record when clicked on, the
CanSelectRecord
trait only has a deselect all method, but no select one.
I have tried
But this threw an error. Any help is appreciated14 Replies
But this threw an error.And you didn't think it would help to share that error? I guess there is no
$this
and it needs to be the id and not the full record:
I will try your idea.
original error:
where are you getting the $livewire from? it is not passed in automatically for me
throws too few arguments
Oh then you probably were right with
$this
using the id as you said throws the same error in a different flavor:
return fn($record) => $this->selectedTableRecords[] = $record->id;
Right. It expects a method that returns an action. So you need to wrap your logic in another method or an action
swapped out
getTableRecordActionUsing
out for getTableRecordAction()
the dd does indeed dd the id of said record but when clicking now it does nothing- with no error, when diedumping dd($this->selectedTableRecords);
it does dump the right id.. but it doesnt select it in the frontendI don’t really know if this is used in the Frontend since it’s alpine based. Guess you need to check out the source code
I do not have time to do so at the moment(this is for work haha), besides its more of a nice to have
Will leave this open for a day or two in case someone else might want to look into it. Cheers for trying to help!
Have you tried to use getAllSelectableTableRecordKeys() ?
That’s for fetching them not setting
Yeah but should work?
Not sure how that should work to select a specific record
I do not want to select all records.. And this has the same problem, it throws no error but does not select them either. It seems the table is not automatically updated when the selectedTableRecords array is changed.
and I dont know what event is emitted normally, that should fix it.. I think