© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
14 replies
KarlisJ

Query only toggled/displayed columns

I have a table with 100+ columns and for performance reasons the table displays only limited amount of them using
toggleable(
toggleable(
. However, all columns are selected from DB.

First I thought that it's a bug, why wouldn't Filament select only the columns that are defined on table but then realised that developer can set state using full record.

So I'm looking for a way to manually set the query with
select(
select(
but for that I need to access toggled columns. Is there a way to do that?
Solution
The query need to be set as closure
$table->query(function () {
   // obtain $query 
   // get $selectableColumns from script above
   return $query->select($selectableColumns)->addSelect('id');
})
$table->query(function () {
   // obtain $query 
   // get $selectableColumns from script above
   return $query->select($selectableColumns)->addSelect('id');
})

because session is updated only once the table is initialized. So when user checks new column to toggle, it's not yet in the session. Using closure fixes that.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Persist toggled Columns over Logins
FilamentFFilament / ❓┊help
3y ago
Testing / code covering toggled table columns
FilamentFFilament / ❓┊help
8mo ago
Save toggled columns to user preferences
FilamentFFilament / ❓┊help
3y ago
Only one primary row when toggled in table
FilamentFFilament / ❓┊help
2y ago