如何使用简单的管理对列表中的多个字段进行排序?

How to sort on multiple field inside a list with easy admin?

通过简单的管理,您可以对列表的一个字段进行排序。
Symfony - Easy Admin v2: Sorting Entity Listings
但是有什么方法可以对我的列表的多个字段进行排序吗?

您可以覆盖 createListQueryBuildercreateSearchQueryBuilder,如前所述 here

示例:

protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{
    /* @var EntityManager */
    $em = $this->getDoctrine()->getManagerForClass($this->entity['class']);

    /* @var QueryBuilder */
    $queryBuilder = $em->createQueryBuilder()
        ->select('entity')
        ->from($this->entity['class'], 'entity')
        ;

    if (!empty($dqlFilter)) {
        $queryBuilder->andWhere($dqlFilter);
    }

    $queryBuilder->addOrderBy('entity.status', 'ASC');
    $queryBuilder->addOrderBy('entity.createdAt', 'DESC');

    return $queryBuilder;
}