From 7529c67b9f32f56f7fbf4d3cabe16f94855a2f8a Mon Sep 17 00:00:00 2001 From: pedro15 Date: Fri, 21 Mar 2014 16:24:10 +0100 Subject: [PATCH] Filter Select (with int index array options) --- src/ZfcDatagrid/Column/AbstractColumn.php | 10 ++++++---- view/zfc-datagrid/renderer/bootstrapTable/layout.phtml | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ZfcDatagrid/Column/AbstractColumn.php b/src/ZfcDatagrid/Column/AbstractColumn.php index d715a4cc..24a176f6 100644 --- a/src/ZfcDatagrid/Column/AbstractColumn.php +++ b/src/ZfcDatagrid/Column/AbstractColumn.php @@ -424,12 +424,14 @@ public function getFilterDefaultOperation() */ public function setFilterSelectOptions(array $options = null, $noSelect = true) { + // This work also with options with integer based array index such as + // array(0 => 'zero', 1 => 'once', 2 => 'double', 3 => 'triple'....) + if ($noSelect === true) { - $nothing = array( - '' => '-' - ); - $options = array_merge($nothing, $options); + $options[''] = '-'; + $this->setFilterDefaultValue(''); } + $this->filterSelectOptions = $options; } diff --git a/view/zfc-datagrid/renderer/bootstrapTable/layout.phtml b/view/zfc-datagrid/renderer/bootstrapTable/layout.phtml index 26218d14..49a84227 100644 --- a/view/zfc-datagrid/renderer/bootstrapTable/layout.phtml +++ b/view/zfc-datagrid/renderer/bootstrapTable/layout.phtml @@ -119,6 +119,8 @@ if($this->rowClickAction !== null){ foreach ($column->getFilterSelectOptions() as $value => $option) { if ($column->getFilterActiveValue() == sprintf($column->getFilterDefaultOperation(), $value)) { $htmlFilter .= ''; + } else if (($column->getFilterActiveValue() == '') && ($value == '')){ + $htmlFilter .= ''; } else { $htmlFilter .= ''; }