Empty initial state on list resource page?
Hi! Is it possible to start with an empty initial state on the list resource page? We have some very large resources where showing the first x entries is redundant. We only want to start showing results once a filter or search is used. Thanks in advance!
16 Replies
You can overwrite the query and add a false query so it returns 0 results until you filter. You can get the filters via
fn($livewire) => $livewire->activeFilters
I found a way to by default return 0 entries. But how do I remove this
getTableQuery()
change once we start filtering? Can't figure this out. Thanks in advance!
I just found that this question has been asked previously: https://discord.com/channels/883083792112300104/1082256110402162688
However, the provided solution doesn't work as $this->activeFilters
is not found. Should I declare this somewhere?Are you doing this on the resource or the list page since it wouldn't be on the resource
On the list page
I just created a work-around to get it working:
Is $this->table->activeFilters not set? I had a feeling it was but could be wrong
This returns an
Undefined property: Filament\Tables\Table::$activeFilters
I was hoping that the active filters would be stored somewhere as the work-around is a bit cumbersome and inefficient. For so far no luck finding itCan you share your code? Not sure why it is
Filament\Tables\Table
as it should be on the PageIt is a class that extends the
ListRecords
class, now building the query like this:
And how did your code look like, that produced that error?
I only try some debug coding, using a
dd()
using the following line as suggested by @toeknee_iom.
What was the issue with
$this->activeFilters
as in my original suggestion and the one in the post you linked!?Also resulted in an error:
Property [$activeFilters] not found on component
When using something like: dd($this->activeFilters);
The tables active filters are stored in
tableFilters
not activeFilters
Yeah, just figured that out, too. I guess I was misleaded by
$activeTab
Make sure this doesn’t give you a false negative when a ternaryFilter is active but false
Thank you very much for the help!