Accessing Selected Records on Page without BulkActions

I have a custom page with a table that allows users to select records. The issue is that I can’t find a way to access the selected records directly from my page. When I use BulkActions, it works fine, but that’s not the behavior I want. Here’s what I’m trying to achieve: At the end of the page, I have a button that triggers a save function. In this function, I need access to all the selectedRecords. What I’ve noticed is: The information is available only after I click on a BulkAction button. It seems like the selection only gets synced with my page at that point. My questions: Is there a way to force the page to always stay in sync with the selected records (even if it comes with a performance cost)? Or is this simply not possible with the current setup?
Solution:
Ok i kinda found the solution that i was looking for. You can give the table a property where the selected records should be entangled on. return $table...
Jump to solution
1 Reply
Solution
muesker
muesker3w ago
Ok i kinda found the solution that i was looking for. You can give the table a property where the selected records should be entangled on. return $table ->records(fn (self $livewire) => $livewire->data) ->selectable() ->currentSelectionLivewireProperty('YOUR_PROPERTY_NAME') A nice feature would be to be to get live updates on selection. I need to build a sum for all selected entries and this should update after a new entry got selected. If any of you guys know how i could do that it would help a lot.

Did you find this page helpful?