Persist sort order

Hi. Can user selected sort be persisted on an relationshipManager table? Thanks
Solution:
Maybe this functionality was added later? But this is plain Filament: ```php // Resource class public static function table(Table $table): Table {...
Jump to solution
40 Replies
awcodes
awcodes5mo ago
Relation managers are just tables.
PabloZagni
PabloZagniOP5mo ago
Yes! Filters can be persisted... but can Orders be persisted?
awcodes
awcodes5mo ago
Maybe I’m just not understanding the difference. A table represents the records of a model.
PabloZagni
PabloZagniOP5mo ago
In my table, ther are many sortable columns. Created_at, name User would like to see records by some sort column...
awcodes
awcodes5mo ago
And those model can be filtered and or persisted with a url query.
PabloZagni
PabloZagniOP5mo ago
for example, user A like the table sorted by name, and user B like like to see the table sorted by created_at by default
awcodes
awcodes5mo ago
Then you need a way to track the user preferences.
PabloZagni
PabloZagniOP5mo ago
filters are persisted. it would be nice to have the sort persisted to... I'm I telling it right? some users would like to see created_at DESC, and some ASC... to see the last change first...
awcodes
awcodes5mo ago
It sounds sounds like you want that at a user level though. So you need some kind of persistence at the user level to to set that via a middleware. But that becomes an app level specification and not a filament one. Filament is still just laravel. So however you would handle it without filament still applies.
PabloZagni
PabloZagniOP5mo ago
I'm developing a process control system Users creates "issues" Then, an ISSUE has same Progress User can add a comment, then attach a file, change ISSUE priority, etc. Each actions generates a log in a table So, the ISSUE viewPage has a relationshipManager with that log. Here's the case... some users would like to see the log ASC, and others DESC. So.. they select the order like this
PabloZagni
PabloZagniOP5mo ago
No description
PabloZagni
PabloZagniOP5mo ago
Filter are persisted with persistFiltersInSession Is there a persistSortsInSession ?
awcodes
awcodes5mo ago
Not to my knowledge
PabloZagni
PabloZagniOP5mo ago
so the user sees the data in the table sorted as he left it Great! Thank you SO MUCH for your time... really Filament is great, takes us time to adapt, but I see it very powerfull
awcodes
awcodes5mo ago
I meant. Filament can handle this, but you need a way to persist the user preferences which falls outside the scope of what filament does. Filament can certainly handle it. But you have to define that distinction. Just sounds like an app specific use case to me. But filament will let your define the query in in way you sit fit.
PabloZagni
PabloZagniOP5mo ago
when I grow up, and my mind understand the core, I'll try to collaborate to add the feature
awcodes
awcodes5mo ago
That’s kind of the beauty of it. It’s a sane default but sometimes your app needs more. And it allows you to do it. My advice is to remember that it’s still just laravel. And don’t get caught up in trying to do things in a filament way. You still have all the control for your apps needs.
PabloZagni
PabloZagniOP5mo ago
Yes... but I need to understand the core... how to interact in Filament..
awcodes
awcodes5mo ago
There’s nothing magical about filament. It’s just a normal laravel lifecycle. Or livewire lifecycle I hear you though. “Interact” can be objective, but it still just laravel and livewire.
PabloZagni
PabloZagniOP5mo ago
I have projects in Laravel 5, MVC, bootstrap Then, laravel 11 with tailwind and jetstream then Laravel 11 with filament somewhere was VUE and Livewire... So many technologies...
awcodes
awcodes5mo ago
Understandable, but that’s outside the scope of filament.
PabloZagni
PabloZagniOP5mo ago
Yes! but I spent 30 minutes googling on how to access the current record to build a custom action... I'm learning... 😄
awcodes
awcodes5mo ago
I get it. Definitely not saying you’re doing anything wrong. But using filament has an implied understanding of the tall stack.
PabloZagni
PabloZagniOP5mo ago
I'm happy I could build the action...
awcodes
awcodes5mo ago
And this looks good.
PabloZagni
PabloZagniOP5mo ago
I'm up to it!
awcodes
awcodes5mo ago
Don’t doubt it. V4 will clean some of this up.
PabloZagni
PabloZagniOP5mo ago
Yeah! it works! I'm very happy... but It take time to switch my mind... and understand everything... I'm gettin progress!
awcodes
awcodes5mo ago
I do feel there’s an educational disconnect with actions currently but v4 will be better. You’ll. Get there. But I understand the disconnect.
PabloZagni
PabloZagniOP5mo ago
again.. thanks to you and all the team... now that I can tell you directly... thanks
awcodes
awcodes5mo ago
And it’s not always easy to describe in docs. We’re doing the best we can right now.
PabloZagni
PabloZagniOP5mo ago
Docs are great! clear! but we are so lazzy to read!! jajajaj I'm visual learner... I like videos
awcodes
awcodes5mo ago
💯 I’m the same way.
PabloZagni
PabloZagniOP5mo ago
but they are all basic... I didn't find intermediate or advanced
awcodes
awcodes5mo ago
Yea. And that’s tough.
PabloZagni
PabloZagniOP5mo ago
Thanks again! I'll continue coding and let you do your stuff.. so many thanks for your time and patience! Greatings from Argentina.
awcodes
awcodes5mo ago
Greeting from a monsoon in Savannah ga. USA. Lol
Solution
John
John3mo ago
Maybe this functionality was added later? But this is plain Filament:
// Resource class
public static function table(Table $table): Table
{
return $table
->persistFiltersInSession()
->persistSortInSession()
->persistSearchInSession()
// ...
}
// Resource class
public static function table(Table $table): Table
{
return $table
->persistFiltersInSession()
->persistSortInSession()
->persistSearchInSession()
// ...
}
PabloZagni
PabloZagniOP3mo ago
Excellent!!!!
Want results from more Discord servers?
Add your server