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
awcodes3mo ago
Relation managers are just tables.
PabloZagni
PabloZagni3mo ago
Yes! Filters can be persisted... but can Orders be persisted?
awcodes
awcodes3mo ago
Maybe I’m just not understanding the difference. A table represents the records of a model.
PabloZagni
PabloZagni3mo ago
In my table, ther are many sortable columns. Created_at, name User would like to see records by some sort column...
awcodes
awcodes3mo ago
And those model can be filtered and or persisted with a url query.
PabloZagni
PabloZagni3mo 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
awcodes3mo ago
Then you need a way to track the user preferences.
PabloZagni
PabloZagni3mo 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
awcodes3mo 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
PabloZagni3mo 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
PabloZagni3mo ago
No description
PabloZagni
PabloZagni3mo ago
Filter are persisted with persistFiltersInSession Is there a persistSortsInSession ?
awcodes
awcodes3mo ago
Not to my knowledge
PabloZagni
PabloZagni3mo 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
awcodes3mo 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
PabloZagni3mo ago
when I grow up, and my mind understand the core, I'll try to collaborate to add the feature
awcodes
awcodes3mo 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
PabloZagni3mo ago
Yes... but I need to understand the core... how to interact in Filament..
awcodes
awcodes3mo 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
PabloZagni3mo 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
awcodes3mo ago
Understandable, but that’s outside the scope of filament.
PabloZagni
PabloZagni3mo ago
Yes! but I spent 30 minutes googling on how to access the current record to build a custom action... I'm learning... 😄
awcodes
awcodes3mo ago
I get it. Definitely not saying you’re doing anything wrong. But using filament has an implied understanding of the tall stack.
PabloZagni
PabloZagni3mo ago
I'm happy I could build the action...
awcodes
awcodes3mo ago
And this looks good.
PabloZagni
PabloZagni3mo ago
I'm up to it!
awcodes
awcodes3mo ago
Don’t doubt it. V4 will clean some of this up.
PabloZagni
PabloZagni3mo ago
Yeah! it works! I'm very happy... but It take time to switch my mind... and understand everything... I'm gettin progress!
awcodes
awcodes3mo 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
PabloZagni3mo ago
again.. thanks to you and all the team... now that I can tell you directly... thanks
awcodes
awcodes3mo ago
And it’s not always easy to describe in docs. We’re doing the best we can right now.
PabloZagni
PabloZagni3mo ago
Docs are great! clear! but we are so lazzy to read!! jajajaj I'm visual learner... I like videos
awcodes
awcodes3mo ago
💯 I’m the same way.
PabloZagni
PabloZagni3mo ago
but they are all basic... I didn't find intermediate or advanced
awcodes
awcodes3mo ago
Yea. And that’s tough.
PabloZagni
PabloZagni3mo 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
awcodes3mo ago
Greeting from a monsoon in Savannah ga. USA. Lol
Solution
John
John2mo 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
PabloZagni2mo ago
Excellent!!!!
Want results from more Discord servers?
Add your server