Toggle selected table row

Can I use getTableRecordAction to toggle the selected row? E.g on click of the row if check/unchecks the selection checkbox. Only way I've found to do this is by adding this to every column
->extraCellAttributes(fn ($record) => ['x-on:click' => "areRecordsSelected([{$record->id}]) ? deselectRecords([{$record->id}]) : selectRecords([{$record->id}])"])
->extraCellAttributes(fn ($record) => ['x-on:click' => "areRecordsSelected([{$record->id}]) ? deselectRecords([{$record->id}]) : selectRecords([{$record->id}])"])
Ideally, I'd like to do it like this:
protected function getTableRecordActionUsing(): ?\Closure
{
return fn ($recordKey): string => "areRecordsSelected([{$recordKey}]) ? deselectRecords([{$recordKey}]) : selectRecords([{$recordKey}])";
}
protected function getTableRecordActionUsing(): ?\Closure
{
return fn ($recordKey): string => "areRecordsSelected([{$recordKey}]) ? deselectRecords([{$recordKey}]) : selectRecords([{$recordKey}])";
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server