How to set table default empty, until user has filtered

Hi everyone, since i have too many records for a relation and it takes too long to render all the records, how can i set the table to be default empty, until the user has filtered out possible options or values.
5 Replies
Dan Harrin
Dan Harrin2y ago
isnt this what pagination is for?
BATMAN
BATMANOP2y ago
i know, but it take too long to load, wanna let the user to filter first
Dennis Koch
Dennis Koch2y ago
Maybe you should optimize your query if a paginated result takes too long. Apart from that you can hack this via getTableQuery and $this->activeFilters on the ListPage
BATMAN
BATMANOP2y ago
ok thx alot
Dennis Koch
Dennis Koch2y ago
Like this:
public function getTableQuery()
{
return parent::getTableQuery()
->when(
count($this->tableFilters) == 0,
fn ($query) => $query->where(DB::raw(1 = 0)),
);
}
public function getTableQuery()
{
return parent::getTableQuery()
->when(
count($this->tableFilters) == 0,
fn ($query) => $query->where(DB::raw(1 = 0)),
);
}
Want results from more Discord servers?
Add your server