Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’2y agoβ€’
6 replies
pepperoni dogfart

Clickable row add to bulk select

Alright this is super hacky but I haven't found a better way yet (feel free to point and laugh πŸ˜†). Looking for some advise cause eventually I'd like to reference the selected rows to update a widget values. (I opened a separate help post about that one)

My goal was to change the default behavior on a table row so that when clicked, it simply selects it to be used for a bulk action instead of opening view/edit, etc.

$table
  ->recordClasses('clickable-row')
  ->recordAction(null)
$table
  ->recordClasses('clickable-row')
  ->recordAction(null)


Here's where it runs a bit astray. I'm sure there's some method to do this with alpine/livewire, what have you - direct in the Resource, but I wasn't able to figure it out. I instead created a new JS asset, imported in a provider as follows:

FilamentAsset::register([
            \Filament\Support\Assets\Js::make('custom-script', __DIR__.'/../../resources/js/custom.js'),
        ]);
FilamentAsset::register([
            \Filament\Support\Assets\Js::make('custom-script', __DIR__.'/../../resources/js/custom.js'),
        ]);


custom.js
document.addEventListener('DOMContentLoaded', function () {
    document.querySelectorAll('.clickable-row').forEach(function (row) {
        row.addEventListener('click', function (event) {
            if (event.target.closest('button') || event.target.closest('a') || event.target.closest('.action-buttons')) {
                return;
            }

            let checkbox = row.querySelector('input[type="checkbox"]');
            if (checkbox) {
                checkbox.checked = !checkbox.checked;
                checkbox.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
    });
});
document.addEventListener('DOMContentLoaded', function () {
    document.querySelectorAll('.clickable-row').forEach(function (row) {
        row.addEventListener('click', function (event) {
            if (event.target.closest('button') || event.target.closest('a') || event.target.closest('.action-buttons')) {
                return;
            }

            let checkbox = row.querySelector('input[type="checkbox"]');
            if (checkbox) {
                checkbox.checked = !checkbox.checked;
                checkbox.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
    });
});


It does work, mostly. Sometimes I'm not able to click them anymore when using table search for example, suspecting the DOM is updated and not reattaching this. Either way, this doesn't feel ideal - any suggestions or insight on a better way to obtain this same behavior?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel β€’ Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Default clickable row action
FilamentFFilament / β“β”Šhelp
3y ago
Clickable defaultGroup, instead of row
FilamentFFilament / β“β”Šhelp
2y ago
Make single row not clickable
FilamentFFilament / β“β”Šhelp
3y ago
V3 clickable row at widget
FilamentFFilament / β“β”Šhelp
3y ago