© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
sm

TableWidget interactions with livewire events.

Hey there,

I'm trying to understand how tablewidgets interact with livewire events.

My structure is: Resource that has a custom field, which renders a tablewidget through livewire.
The resource has an event defined in its
EditResource
EditResource
, and the
TableWidget
TableWidget
has an event defined in it (both using
On
On
attribute).

The
table($table)
table($table)
function on the
TableWidget
TableWidget
has default query builder, basically modelClass::query(). It also has an
Action
Action
, which fires an event which the
EditResource
EditResource
is listening for. All of this works fine.

The
Resource
Resource
has a set of filters (not filament filters, custom filters built using a form component). When these are updated, the
Resource
Resource
fires an event which the
TableWidget
TableWidget
listens for in a func called
updateFilters
updateFilters
. The
updateFilters
updateFilters
func receives the filters from the event, and updates the
TableWidget
TableWidget
's query (by doing
$this->query(modelClass::getFiltersFromEventData($filters));
$this->query(modelClass::getFiltersFromEventData($filters));
).. this works.

The TableWidget has an
Add
Add
action attached to it, this just fires a livewire event (on $livewire) to indicate to the resource that a new record has been selected by the user. This is the event that the function in
EditResource
EditResource
listens for, it attaches the selected record (using the id from the event) to the resource's modelClass.

This is where things get a bit funky: after that event is fired, the table widget's
table($table)
table($table)
func gets called again, which resets the query builder (because it has ->query(modelClass::query())), resetting all the filters..

My understanding is that
table($table)
table($table)
would only be called once on initialization, is this not the case? How can I preserve the Builder? I've tried adding a
protected $filtersState
protected $filtersState
to the
TableWidget
TableWidget
, but that causes all kinds of weird race conditions.. and I feel like I'm missing something obvious.

Any pointers?

Thanks!
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

TableWidget
FilamentFFilament / ❓┊help
3y ago
TableWidget with morphTo and groupedBy
FilamentFFilament / ❓┊help
3y ago
TableWidget will not sort with getStateUsing
FilamentFFilament / ❓┊help
15mo ago
Tabs in TableWidget
FilamentFFilament / ❓┊help
6mo ago