sonata-project/SonataAdminBundle — pull request #2527 by mrdavecox (2014-10-27 11:04:51+00:00)
Title: Update action_list.rst

Problem:
The documentation currently lacks instructions regarding how to configure the default ordering in the list view using multiple columns.

Solution:
I have made changes to the documentation showing how to override the createQuery method (based on code kindly provided here: https://github.com/sonata-project/SonataAdminBundle/issues/1548). However, one of the problems with overriding the createQuery method completely is it then stops admin users being able to sort columns by clicking on the column headings. The proposed changes check the filter parameter of the query string to see whether the user is viewing the default view or whether a filter has been applied. If the filter has been applied, then the parent method is returned as normal, otherwise the custom query is created and returned by the createQuery class.

The example uses a simple Product/Category entity relationship, as this would seem a pretty common case for when developers would want to sort by multiple columns when users arrive at the default Product list view.