© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
Jakub

multiple values for default sort on tables

In this question somone suggested this method

protected function applyDefaultSortingToTableQuery(Builder $query, string $sortColumn, string $sortDirection): Builder
{
    return $query
        ->orderBy('category', 'ASC')
        ->orderBy('title', 'ASC');
}
protected function applyDefaultSortingToTableQuery(Builder $query, string $sortColumn, string $sortDirection): Builder
{
    return $query
        ->orderBy('category', 'ASC')
        ->orderBy('title', 'ASC');
}


❓┊helpFor defaultSort() which accepts a string, is there an easy way to sort by multiple columns?

I don't see this in documentation for V3, is this still doable?


When I added it MilestoneResource.php nothing happens

    protected function applyDefaultSortingToTableQuery(Builder $query, string $sortColumn, string $sortDirection): Builder
    {
        return $query
            ->orderBy('status', 'asc')
            ->orderBy('created_at', 'asc');
    }
    protected function applyDefaultSortingToTableQuery(Builder $query, string $sortColumn, string $sortDirection): Builder
    {
        return $query
            ->orderBy('status', 'asc')
            ->orderBy('created_at', 'asc');
    }


When I added to a page like ListMilestones.php i get this error
27429b95c7a102a704ceb03e5dda3d4c.png
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

Multiple default sort in tables
FilamentFFilament / ❓┊help
3y ago
Pagination default value on tables
FilamentFFilament / ❓┊help
3y ago
Default Pagination for all tables
FilamentFFilament / ❓┊help
3y ago
Multiple tables on same page
FilamentFFilament / ❓┊help
3y ago