Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default sort with multiple fields not in the same direction #765

Open
tsiatka opened this issue May 2, 2023 · 1 comment
Open

Set default sort with multiple fields not in the same direction #765

tsiatka opened this issue May 2, 2023 · 1 comment

Comments

@tsiatka
Copy link

tsiatka commented May 2, 2023

Q A
Bundle version 6.2.0
Symfony version 6.2.10
PHP version 8.1.10

Support Question

Sorry in advance, I'm not really sure if it's a feature request or if I don't know how to achieve it with the bundle.
I'm trying to sort by default with multiple fields.

With the EasyAdmin bundle you're able to achieve what I'm looking for with the setDefaultSort() method :
https://symfony.com/bundles/EasyAdminBundle/4.x/crud.html#search-order-and-pagination-options

->setDefaultSort(['title' => 'ASC', 'startsAt' => 'DESC'])

As you can see, you're able to sort by multiple fields. Using the example above, if two entities have the same title, EasyAdmin sort the entities by date.

I think this feature could be very useful in the paginate() method.
Maybe by merging the 'defaultSortFieldName' & 'defaultSortDirection' parameters ?

Thanks

@garak
Copy link
Collaborator

garak commented Sep 11, 2023

The filter/sorting functionality only offers some basic features.
For any advanced needs, you should implement your logic and use the paginator only to paginate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants