© 2026 Hedgehog Software, LLC

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

Only show header action if table has records

Is there a better(performance/cached) way of only showing a header action if the table has records?
$table->query()
    ->columns([])
    ->headerActions([
        ExportAction::make('Export')
            ->visible(fn () => $this->table->getRecords()->isNotEmpty()),
$table->query()
    ->columns([])
    ->headerActions([
        ExportAction::make('Export')
            ->visible(fn () => $this->table->getRecords()->isNotEmpty()),
Solution
So, looking into the table component, it calls $records = $getRecords() and also uses count($records) ... so, what you're doing is probably fine.
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

How to get all table records in header action
FilamentFFilament / ❓┊help
2y ago
Records count in table header
FilamentFFilament / ❓┊help
2y ago
Create table header action question...
FilamentFFilament / ❓┊help
3y ago
Show table row action only when filter is enabled
FilamentFFilament / ❓┊help
2y ago