Custom sort option

Not sure if I'm missing something but I can't find anything relevant in the docs/online Is there a way to add a custom sort option, without having the related column appear on the table? Eg I might want to sort by the ID column, without having the ID visible on the table. I tried having a hidden column but it didn't work.
TextColumn::make('ID')
->hidden()
->sortable()
TextColumn::make('ID')
->hidden()
->sortable()
Any idea/tips? Thanks in advance
Solution:
What about ```php TextColumn::make('ID') ->toggleable(isToggledHiddenByDefault: true)...
Jump to solution
9 Replies
Adam
Adam3mo ago
Do you mean that you want to sort the table by its ID by default?
ChesterS
ChesterSOP3mo ago
Sorry, no. I want to have an option to sort by ID without having a column visible. Eg in the Filament demo site, I'd like this Without having a TextColumn::make('ID')->sortable() From what i can see, this is not possible, but I might be missing something
ChesterS
ChesterSOP3mo ago
No description
toeknee
toeknee3mo ago
Looks like you are using the grid with sortable. I don't think it's possible... Maybe if you add a hidden extra attributes class to the header and cell attributes as the code would still bring it into the sortable select.
ChesterS
ChesterSOP3mo ago
Yeah I guess I can hide it with CSS but that's too hacky even for me haha 😂 Anyway, thank you all for your time
Solution
toeknee
toeknee3mo ago
What about
TextColumn::make('ID')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
TextColumn::make('ID')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
ChesterS
ChesterSOP3mo ago
Yeah I thought about it but for some reason doesn't work as expected in my case. The columns remain visible no matter what? Weird stuff :/
toeknee
toeknee3mo ago
Possibly the split view/grid?
ChesterS
ChesterSOP3mo ago
Ah shit yeah, that's it 🤦 Oh well, I'll have to look into it. I'll accept your answer since it's the most sane workaround

Did you find this page helpful?