symfony - Sonata Admin configureListFields -
is possible make custom query in sonataadmin in configurelistfields ? .
in function :
protected function configurelistfields(listmapper $listmapper) { $listmapper ->>add(.... ; }
thank !
you should override createquery
method (source):
public function createquery($context = 'list') { $query = parent::createquery($context); // queryproxy, can call call on doctrine orm querybuilder $query->andwhere( $query->expr()->eq($query->getrootalias().'.username', ':username') ); $query->setparameter('username', 'test'); // eg security context return $query; }
afaik, cannot change select
part of query , cannot use group by
, because internally sonata runs query @ least 2 times. first, checks how many rows query returns. second, runs query paginated.
Comments
Post a Comment