From e575f7f37f5fdfdfb77ad884938787654131a92d Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Fri, 10 Dec 2021 17:09:56 -0500 Subject: [PATCH] Add a setting to use having for column filtering --- Grid/Column/Column.php | 12 ++++++++++++ Grid/Source/Entity.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Grid/Column/Column.php b/Grid/Column/Column.php index 1c25c9f..da0e3b8 100644 --- a/Grid/Column/Column.php +++ b/Grid/Column/Column.php @@ -118,6 +118,7 @@ abstract class Column protected $export; protected $class; protected $isManualField; + protected $useHaving; protected $isAggregate; protected $usePrefixTitle; protected $translationDomain; @@ -156,6 +157,7 @@ public function __initialize(array $params) $this->setValues($this->getParam('values', [])); $this->setOperatorsVisible($this->getParam('operatorsVisible', true)); $this->setIsManualField($this->getParam('isManualField', false)); + $this->setUseHaving($this->getParam('useHaving', false)); $this->setIsAggregate($this->getParam('isAggregate', false)); $this->setUsePrefixTitle($this->getParam('usePrefixTitle', true)); @@ -1010,6 +1012,16 @@ public function getIsManualField() return $this->isManualField; } + public function setUseHaving($useHaving) + { + $this->useHaving = $useHaving; + } + + public function getUseHaving() + { + return $this->useHaving; + } + public function setIsAggregate($isAggregate) { $this->isAggregate = $isAggregate; diff --git a/Grid/Source/Entity.php b/Grid/Source/Entity.php index 518abc8..2f2bfc7 100644 --- a/Grid/Source/Entity.php +++ b/Grid/Source/Entity.php @@ -427,7 +427,7 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr $isDisjunction = $column->getDataJunction() === Column::DATA_DISJUNCTION; $dqlMatches = []; - $hasHavingClause = $column->hasDQLFunction($dqlMatches) || $column->getIsAggregate(); + $hasHavingClause = $column->hasDQLFunction($dqlMatches) || $column->getIsAggregate() || $column->getUseHaving(); if(isset($dqlMatches['function']) && $dqlMatches['function'] == 'translation_agg'){ $hasHavingClause = false; }