Add tablefilter to querystring programatically

I haven't found a solution in the discussions or discord yet. My goal is to have some buttons above the table which should prefill the table filters. And update also the querystring. I don't want to use the querystring direclty (href to some url with the querystring). I would like to use some methods from the HasFilters trait. But I couldn't find a proper one. I only found removeTableFilter but am searching for like addTableFilter. Is there another way of prefilling the table filters to build multiple "sets" for some quick buttons above the table?
13 Replies
krizz3332
krizz3332OP16mo ago
Or is there no easy way and I have to use something like this: https://filamentphp.com/plugins/kenneth-sese-filter-sets ?
Filament
Filter Sets by Kenneth Sese - Filament
Let your users combine their filters, searches, column order, and more into convenient and easily accessible filter sets.
krizz3332
krizz3332OP16mo ago
The thing is I don't need to let the user build their own filter sets. I only need 3-4 static ones for all to be more specific: I want to use getTableHeaderActions() method and add an action which prefills some filter form elements.
Kenneth Sese
Kenneth Sese16mo ago
Just FYI, you don't need to allow users to create their own filter sets. You can define them like you want and not let users make their own I'll also mention that Filament Tabs doesn't fill out the filters for you. It just scopes the eloquent query. That may be enough for your needs, but I'll add that Filter Sets v3 I'll be releasing soon will also allow you to define filters you want to show up in the filters form.
krizz3332
krizz3332OP16mo ago
Hi thanks for your quick respond. Yes I just bought the plug-in , because I need favorites in other scenarios . Yes I just read that developer filters won‘t set the filters , only the scopes. But when I add global user filters for all it will sync with the filters right? Great , time for me to switch to filament 3 then 😂
Kenneth Sese
Kenneth Sese16mo ago
Oh that was you! hahaha! Correct...Global user filters will sync with the filters Then you can disable filter set creation if you don't want the user to be able to create
krizz3332
krizz3332OP16mo ago
Thanks for the plug-in though. Just had some trouble because I come from a legacy project which shifted to laravel 10 and my user_id was still unsignedInteger instead of bigInt 😅
Kenneth Sese
Kenneth Sese16mo ago
And as I mentioned in v3 I hope to release soon, you'll be able to do filter sets in code but ALSO set filters to sync with the form
krizz3332
krizz3332OP16mo ago
no hurry , it will take me some time to shift to filament 3 😜 I‘ll mark this thread as answered as you mentioned the tabs and gave more hints on your package. Thank you a lot !
Kenneth Sese
Kenneth Sese16mo ago
ahh...legacy...always fun
Kenneth Sese
Kenneth Sese16mo ago
Oh and since you're on Filament v2, it might be easier to refer to Filter Sets v1 docs: https://v2.filamentphp.com/plugins/filter-sets
Filament
Filter Sets by Kenneth Sese - Plugins - Filament
Filter Sets lets your users save their filters, search queries, column order, and more into easily accessible filter sets
krizz3332
krizz3332OP16mo ago
Thanks again. Didn’t find the correct link first 🙏 And time for me to scroll through your code to see how you did it ☺️
Kenneth Sese
Kenneth Sese16mo ago
good luck with that! 😬 🤣
Want results from more Discord servers?
Add your server