Table filters result

Hello everyone, Please how to use the result of table filters in my custom action?
15 Replies
Illizian
Illizian2w ago
You're gonna need to give us some more info! It sounds like you just need a bulk action. I think you can also get the current table entries in a table header action too
kobosoft.dev
kobosoft.devOP2w ago
I use header action ->headerActions([ Action::make('exportPdf') ->label('Exporter PDF') ->icon('heroicon-o-document-arrow-down') ->action(function ($livewire) {
return self::generatePdf($records, $livewire); }) ]) here is a piece of my code
Illizian
Illizian2w ago
try:
$this->getFilteredTableQuery()->clone()->get()
$this->getFilteredTableQuery()->clone()->get()
in your action
kobosoft.dev
kobosoft.devOP2w ago
i got this error: Using $this when not in object context
Illizian
Illizian2w ago
Is that just in your LSP? Oh wait....where is your table? Is it a ListResource or custom?
kobosoft.dev
kobosoft.devOP2w ago
yes in ListResource what is LSP sorry I'm a novice
Illizian
Illizian2w ago
Hmm. Where do you see that error? In your IDE, or browser?
kobosoft.dev
kobosoft.devOP2w ago
on browser
Illizian
Illizian2w ago
Oh, in that case you'll have to wait for someone far compotent than I 😅 I'd recommend a bulk action, I think it'll make for better UX too
kobosoft.dev
kobosoft.devOP2w ago
Thanks for the help, but do you have a method with bluk action?
kobosoft.dev
kobosoft.devOP2w ago
THANKS
Solution
Illizian
Illizian2w ago
Illizian
Illizian2w ago
oh, "PDF" the clue was right there in your action title. Not sure it'll support that, probably just csv/xls (I'm also fairly new to filament) looks like this supports: ->action(function($records) {}) which is exactly what you need, but would require the user to hit the "Select All" button once filtered. This would however (for better UX) let them additionally filter it by unticking/ticking the ones they need if the filter isn't enough for their purpose.
kobosoft.dev
kobosoft.devOP2w ago
ok thank you very much I will try that

Did you find this page helpful?