I have a grid that I created using Sylius that works perfectly.
One of the fields in my grid refers to the count of a collection property (Referees).
I am able to show the count of this collection (Referee Count), but I am unable to sort on on it, because the entity being used to populate the grid does return any sort of count on the collection.
The code looks as follows:
The fields in my grid.yml looks like the below:
refereeCount:
type: twig
label: 'Referee Count'
path: 'referees'
sortable: ~
options:
template: AffiliateBundle:admin/referrer:_refereeCount.html.twig
and the refereeCount.html.twig:
{{ data|length }}
My referees property in Referrer.php the entity that is being used to populate the above grid is defined as below:
/**
* @var Referee[]|Collection
*/
private $referees;
As a result, the Gird displays the refereeCount correctly, but I am unable to sort on it.
Does anyone have any advice as to how I would be able to sort on the length of this column?