© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
urbycoz

Using closure with sortable on TextColumn

I've set up my database schema using Eloquent models, and I'm trying to use the customer model in my sortable() method:

TextColumn::make('customer.postcode')
->sortable(query: function (Builder $query, string $direction): Builder {
return $query->whereHas('customer', function (Builder $q) use ($direction) {
$q->orderBy('postcode', $direction);
});
})

...however the sorting doesn't actually seem to work. It sorts the table records but not in any obvious order.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

TextColumn::sortable() issue
FilamentFFilament / ❓┊help
3y ago
Numeric TextColumn: sortable() not working properly
FilamentFFilament / ❓┊help
2y ago
Sortable TextColumn based on Enum labels rather than query
FilamentFFilament / ❓┊help
2y ago
Using limit with default in datatable textcolumn
FilamentFFilament / ❓┊help
2y ago