List View with Group By and Counts

450 views
Skip to first unread message

olemedia

unread,
Jul 21, 2017, 12:45:55 PM7/21/17
to sonata-devs
Is there a way I can create a list view that displays a result set using groupby and count? I would like to maintain the functionality of having filters and the export feature. I guess, another way to ask will be, can I create my own query? not depending on ORM?

Edi Camas

unread,
Jul 22, 2017, 12:56:35 PM7/22/17
to sonata-devs
Yes, you can overryde the list query that sonata generate by using:
public function createQuery($context = 'list'){

}

olemedia

unread,
Jul 23, 2017, 1:53:49 PM7/23/17
to sonata-devs
Thank you very much for getting back to me. But what I'm trying to do is to display in the list view extra fields that are not mapped, meaning that are not in the entity itself, and that are total counts using count and groupby. Something like this:

+------Some Colum -----+----------Type--------+---Total---+
+   Some Value             +   ROLE_ADMIN   +      5       +
+   Some Other value   +   ROLE_FOO       +     10      +

Or another example will be, display total number of players in a team.

Makes sense?

Thanks again in advance.

L.
Reply all
Reply to author
Forward
0 new messages