diff --git a/Grid/Filter/Operator/HavingRange.php b/Grid/Filter/Operator/Having.php similarity index 90% rename from Grid/Filter/Operator/HavingRange.php rename to Grid/Filter/Operator/Having.php index 74abb0f..ea5b4ea 100644 --- a/Grid/Filter/Operator/HavingRange.php +++ b/Grid/Filter/Operator/Having.php @@ -5,7 +5,7 @@ /** * Having */ -class HavingRange extends OperatorAbstract +class Having extends OperatorAbstract { /** * @param array $value diff --git a/Grid/GridAbstract.php b/Grid/GridAbstract.php index 1a0fd90..cfa67c7 100644 --- a/Grid/GridAbstract.php +++ b/Grid/GridAbstract.php @@ -241,7 +241,7 @@ public function getData() foreach ($filters as $filter) { /** @var \PedroTeixeira\Bundle\GridBundle\Grid\Column $column */ foreach ($this->columns as $column) { - if ($filter['name'] == $column->getIndex() && !empty($filter['value'])) { + if ($filter['name'] == $column->getIndex() && $filter['value'] != '') { $column->getFilter()->execute($this->getQueryBuilder(), $filter['value']); } } @@ -281,8 +281,18 @@ public function getData() $rowColumn = ' '; + // Array + if (array_key_exists($column->getField(), $row)) { + + $rowColumn = $row[$column->getField()]; + + // Array scalar + } else if (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) { + + $rowColumn = $row[0][$column->getField()]; + // Object - if (method_exists($row, 'get' . ucfirst($column->getField()))) { + } else if (method_exists($row, 'get' . ucfirst($column->getField()))) { $method = 'get' . ucfirst($column->getField()); $rowColumn = $row->$method(); @@ -294,16 +304,6 @@ public function getData() $rowColumn = $row[0]->$method(); // Array - } else if (array_key_exists($column->getField(), $row)) { - - $rowColumn = $row[$column->getField()]; - - // Array scalar - } else if (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) { - - $rowColumn = $row[0][$column->getField()]; - - // Twig } else if ($column->getTwig()) { $rowColumn = $this->templating->render( diff --git a/Grid/Render/Date.php b/Grid/Render/Date.php index 78abcef..86ac139 100644 --- a/Grid/Render/Date.php +++ b/Grid/Render/Date.php @@ -17,7 +17,9 @@ class Date extends RenderAbstract */ public function render() { - return $this->getValue()->format($this->getDateFormat()); + if ($this->getValue() instanceof \DateTime) { + return $this->getValue()->format($this->getDateFormat()); + } } /** diff --git a/Grid/Render/Url.php b/Grid/Render/Url.php new file mode 100644 index 0000000..53a7931 --- /dev/null +++ b/Grid/Render/Url.php @@ -0,0 +1,17 @@ +getValue() . '" target="_blank">' . $this->getValue() . ''; + } +} \ No newline at end of file diff --git a/Grid/Render/YesNo.php b/Grid/Render/YesNo.php new file mode 100644 index 0000000..94203cd --- /dev/null +++ b/Grid/Render/YesNo.php @@ -0,0 +1,21 @@ +getValue()) { + return ''; + } else { + return ''; + } + } +} \ No newline at end of file