Get table records
i want to get those records show in the filament table even apply filters in closure functions
9 Replies
Try providing some more info
In a Filament table resource, I have created an action button on the list page. I want to export the data displayed in the table, and for that, I need to get the table data in a custom export class. The challenge is to ensure that when filters are applied to the table (e.g., if 5 users are displayed initially and after applying filters, only 2 users remain), the custom export should include only the 2 users shown after filtering. This means that the export should include all the records currently displayed in the table, whether filters are applied or not.
You should be able to access those through
fn ($livewire) => $livewire->getFilteredTableQuery()->get()
its working but if i same thing in UserResources Main File. How i can perform this task
getFilteredTableQuery()
i use this in UserResource main file and it not working
($livewire) => $livewire->getFilteredTableQuery()->get()
Tables\Actions\Action::make('exports')
->label('Export')
->icon('heroicon-s-download')
->color('success')
->action(function ($livewire) : void{
dd($livewire->getFilteredTableQuery()->get());
}),
What kind of action is that? Table header action? Please format your code with backticks (see #✅┊rules )
yes i use in table header action
Hm, I am not sure then. Does it return an empty collection? Try debugging
$livewire->getFilteredTableQuery()
and see what the actual query isno empty collection it return the error getFilteredTableQuery() method does exist in userresources/pages/ListUser.php
Hm. Check the existing methods for the ListRecords class. Maybe I made a typo